Skip to content

user: keep usernames out of console format strings - #90

Merged
msimerson merged 1 commit into
mainfrom
log-format-strings
Oct 16, 2026
Merged

msimerson merged 1 commit into
mainfrom
log-format-strings

Conversation

@msimerson

Copy link
Copy Markdown
Contributor

console.warn and console.error treat their first argument as a format string. Three login log lines interpolated the username into that string and passed err after it, so a username containing %o or %s consumed the error. With username %o%s@example.com the line came out as … for user 'boom'%s@example.com and the error was dropped.

The username is now passed as a %s argument with a constant format string:

  • lib/user/credentials.js:108 (PBKDF2 failure)
  • lib/user/store/file.js:81 and lib/user/store/mysql.js:55 (password hash upgrade failure)

These were the only console calls in the package with an interpolated first argument and more arguments after it. Clears CodeQL js/tainted-format-string alerts 25, 26 and 27.

Tests pass on mysql (597), json (556) and toml (556).

console.warn and console.error treat their first argument as a format
string. With the username interpolated into it, a username holding %o or
%s consumed the error argument, so the log showed the username wrapped
around the error and dropped the error itself. The username is now a %s
argument (CodeQL js/tainted-format-string, alerts 25-27).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

All three targeted replacements correctly isolate usernames from format strings while preserving the error argument.

0 open findings

What changed in this PR

Prevents usernames from being interpreted as console format strings in authentication error logs.

Changes:

  • Uses constant format strings and passes usernames as %s arguments in all three affected logs.
  • Preserves error logging and authentication behavior.
File Description
lib/​user/​store/​mysql.js Safely logs usernames on password hash upgrade failure.
lib/​user/​store/​file.js Applies the same fix to file-backed storage.
lib/​user/​credentials.js Safely logs usernames on PBKDF2 failure.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@msimerson
msimerson merged commit e0ea5df into main Oct 16, 2026
13 of 14 checks passed
@msimerson
msimerson deleted the log-format-strings branch October 16, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants