CVE-2026-105963: Secret key base exposed in stack trace arguments on wrong-typed Plug.Crypto arguments
Externally-Generated Error Message Containing Sensitive Information vulnerability in plugcrypto in elixir-plug plugcrypto allows an unauthenticated remote attacker to expose the secret key base through application logs via a wrong-typed argument. Every public function in Plug.Crypto validates argument types in a function-head guard. A failed guard makes the Erlang VM raise FunctionClauseError with the actual argument values in the top stack frame, so the secret key base, a derived key, or the value an API key is compared against lands in that frame. The library's rescue blocks and Plug.Crypto.pruneargsfromstacktrace/1 only reach exceptions raised inside a function body, so they never see a guard failure. Plug.Cowboy and Bandit write the frame to the error log and attach it as crashreason Logger metadata, which error trackers forward.
Two entry points take request data. Plug.Crypto.verify/4 exposes the secret key base when the token is neither a binary nor nil, which Phoenix.Token.verify/4 reaches because it forwards the token unguarded. Plug.Crypto.securecompare/2 exposes the other operand when one side is not a binary, as happens when a missing request header yields nil. Reading the leaked value needs separate access to the logs or the error tracker, so the request alone does not disclose the secret to the attacker.
This issue affects plug: from 1.6.3 before 1.7.0; plugcrypto: from 1.0.0 before 2.2.1.
Affected Software
Event History
Frequently Asked Questions
Which request paths can expose secrets to an unauthenticated attacker?
The affected paths are Plug.Crypto.verify/4 when it receives a token that is neither a binary nor nil, including calls reached through Phoenix.Token.verify/4, and Plug.Crypto.secure_compare/2 when either operand is not a binary. A missing request header can produce nil for the secure_compare/2 case.
What information can be written to logs or error trackers?
The top stack frame can contain the secret key base, a derived key, or the value being compared to an API key. Plug.Cowboy and Bandit write this frame to the error log and attach it as crash_reason Logger metadata, which error trackers may forward.
Does a normal malformed token trigger the verify/4 exposure condition?
The described verify/4 condition requires a token value that is neither a binary nor nil. A malformed value that remains a binary is not identified in the provided data as meeting that condition.
Why do the library's stack-trace sanitization mechanisms not prevent this logging?
The failure occurs in a function-head type guard, causing the Erlang VM to raise FunctionClauseError before the function body executes. The library's rescue blocks and prune_args_from_stacktrace/1 only handle exceptions raised inside the function body.