Am I affected?

type your ash_authentication version to check

Description

Authentication Bypass by Spoofing vulnerability in team-alembic ash_authentication allows an attacker who can plant a remember-me cookie in a victim's browser to replace that victim's authenticated session with one for the attacker's own account.

AshAuthentication.Plug.Helpers.sign_in_using_remember_me/3 skips re-authenticating an already-signed-in visitor by checking the session for "<subject_name>_token", but store_in_session/2 writes that key only when require_token_presence_for_authentication? is enabled and otherwise writes the bare subject name. At the default setting the guard therefore reads a key that is never written, its already-signed-in branch is unreachable, and the remember-me sign-in runs on every request through the per-request browser pipeline plug. A planted remember-me cookie is consequently honoured even for a visitor holding a live authenticated session, so whatever the victim enters afterwards lands in data the attacker controls. The read path in authenticate_resource_from_session/4 selects the key correctly, so the guard and the reader disagree about which key holds the session.

This issue affects ash_authentication: from 4.10.0 before 4.15.0 and from 5.0.0-rc.0 before 5.0.0-rc.14.

Weaknesses & attack patterns

Weakness

CWE-290 · Authentication Bypass by Spoofing in catalog → MITRE ↗

Attack patterns

CAPEC-21 · Exploitation of Trusted Identifiers MITRE ↗

An attacker who can set a remember-me cookie in a victim's browser silently replaces the victim's authenticated session with one for the attacker's own account, so data the victim subsequently enters is written to records the attacker controls. The victim is given no indication their identity changed.

Affected — Hex / ash_authentication Hex.pm ↗ Repository ↗

4.10.0 < 4.15.0 affected
5.0 series 5.0.0-rc.0 < 5.0.0-rc.14 affected
every other version: unaffected
cpe cpe:2.3:a:team-alembic:ash_authentication:*:*:*:*:*:*:*:*
modules · source files · routines
modules 'Elixir.AshAuthentication.Plug.Helpers'
source files lib/ash_authentication/plug/helpers.ex
routines 'Elixir.AshAuthentication.Plug.Helpers':sign_in_using_remember_me/3 · 'Elixir.AshAuthentication.Plug.Helpers':store_in_session/2

Affected — GitHub / team-alembic/ash_authentication Repository ↗

3d3de31 and up affected
b9568a5 not affected
9a34136 not affected
every other version: unaffected
cpe cpe:2.3:a:team-alembic:ash_authentication:*:*:*:*:*:*:*:*
modules · source files · routines
modules 'Elixir.AshAuthentication.Plug.Helpers'
source files lib/ash_authentication/plug/helpers.ex
routines 'Elixir.AshAuthentication.Plug.Helpers':sign_in_using_remember_me/3 · 'Elixir.AshAuthentication.Plug.Helpers':store_in_session/2

Workarounds

Set require_token_presence_for_authentication? true on the authenticated resource's token configuration. store_in_session/2 then writes the key the guard reads, so the already-signed-in branch fires and the remember-me sign-in no longer runs against a live session. Note this changes session storage semantics for the whole application and requires a token resource.

Otherwise remove the remember-me plug from the browser pipeline, which disables remember-me auto-login entirely.

Configurations

The application must enable the remember_me strategy and run its per-request plug in the browser pipeline, with require_token_presence_for_authentication? at its default of false. Enabling that setting makes the guard read the key the session actually holds, which closes the issue.

The attacker also needs a position from which to set a cookie in the victim's browser, such as cookie tossing from a sibling subdomain, an HTTP host without HSTS, or a shared or kiosk browser.

References

Credits

Peter Ullrich Reporter
James Harton Remediation developer
Jonatan Männchen / EEF Coordinator

CVSS breakdown

CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N
« All CVEs