Am I affected?

type your ash_authentication version to check

Description

Insertion of Sensitive Information into Log File vulnerability in team-alembic ash_authentication allows a reader of the audit log to sign in as any user who has signed in with an API key.

The audit_log add-on records every public argument of an audited action that is not marked sensitive?. The API key sign-in action written by mix ash_authentication.add_strategy.api_key, the API keys guide and the usage rules declares api_key without sensitive?, and nothing required it, so every API key sign-in, including each request AshAuthentication.Strategy.ApiKey.Plug authenticates, stored the plaintext key in the entry's extra_data. The application keeps only key hashes, but anyone who can read the audit table, its backups or an admin view of it obtains working keys. Magic link and confirmation tokens, one-time passwords, and TOTP and recovery codes were stored the same way when the action did not mark them sensitive.

This issue affects ash_authentication: from 4.12.0 before 4.15.2 and from 5.0.0-rc.0 before 5.0.0-rc.19.

Weaknesses & attack patterns

Weakness

CWE-532 · Insertion of Sensitive Information into Log File in catalog → MITRE ↗

Attack patterns

CAPEC-560 · Use of Known Domain Credentials MITRE ↗

A reader of the audit store takes a logged API key and signs in as its user through the API key strategy, with that user's permissions, until the key is revoked.

Affected — Hex / ash_authentication Hex.pm ↗ Repository ↗

≥ 4.12.0 < 4.15.2 affected
5.0 series ≥ 5.0.0-rc.0 < 5.0.0-rc.19 affected
every other version: unaffected
cpe cpe:2.3:a:team-alembic:ash_authentication:*:*:*:*:*:*:*:*
version type semver
modules · source files · routines
modules 'Elixir.AshAuthentication.AddOn.AuditLog.Transformer' · 'Elixir.AshAuthentication.AddOn.AuditLog.Auditor'
source files lib/ash_authentication/add_ons/audit_log/transformer.ex · lib/ash_authentication/add_ons/audit_log/auditor.ex
routines 'Elixir.AshAuthentication.AddOn.AuditLog.Transformer':persist_logged_fields/3 · 'Elixir.AshAuthentication.AddOn.AuditLog.Auditor':get_params/2

Affected — GitHub / team-alembic/ash_authentication Repository ↗

≥ 255cfc9 and up affected
→ 5083af2 not affected
→ f7271f4 not affected
every other version: unaffected
cpe cpe:2.3:a:team-alembic:ash_authentication:*:*:*:*:*:*:*:*
version type git
modules · source files · routines
modules 'Elixir.AshAuthentication.AddOn.AuditLog.Transformer' · 'Elixir.AshAuthentication.AddOn.AuditLog.Auditor'
source files lib/ash_authentication/add_ons/audit_log/transformer.ex · lib/ash_authentication/add_ons/audit_log/auditor.ex
routines 'Elixir.AshAuthentication.AddOn.AuditLog.Transformer':persist_logged_fields/3 · 'Elixir.AshAuthentication.AddOn.AuditLog.Auditor':get_params/2

Workarounds

Mark the api_key argument of the API key sign-in action sensitive?: true, and do the same for any secret argument of a magic link, OTP, TOTP, recovery code or confirmation action the application defines. Alternatively, add the sign-in action to the audit log's exclude_actions. Neither removes keys already logged; see the solution.

Configurations

The audit_log add-on is enabled and the api_key strategy's sign-in action does not mark its api_key argument sensitive?: true, which is how the generator, the API keys guide and the usage rules write it. The other secrets are exposed only when the action the application defines for them omits sensitive?. Fields named in include_fields are logged by design.

Solutions

Upgrade to 4.15.2 or 5.0.0-rc.19. The audit log then never records a strategy's secret arguments unless include_fields names them, and an API key sign-in action whose argument is not sensitive compiles with a warning.

Upgrading does not remove keys already logged. Treat every API key used while the add-on was enabled as exposed and revoke it; the middle segment of each key encodes the id of its API key record. Remove the keys from existing entries, for example on PostgreSQL with UPDATE <audit_log_table> SET extra_data = extra_data #- '{params,api_key}' WHERE extra_data->'params' ? 'api_key';, and account for backups, replicas and exports of the audit table.

References

Credits

Glenn Rempe Reporter Remediation developer
Zach Daniel Coordinator Remediation reviewer

CVSS breakdown

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

Exploitability

Attack Vector
Local
Attack Complexity
Low
Attack Requirements
None
Privileges Required
High
User Interaction
None

Vulnerable System

Confidentiality
High
Integrity
None
Availability
None

Subsequent Systems

Confidentiality
None
Integrity
None
Availability
None
« All CVEs