Skip to content

Stop printing GitHub secrets to the server log - #505

Merged
jarstelfox merged 1 commit into
masterfrom
stop-logging-secrets
Sep 30, 2026
Merged

jarstelfox merged 1 commit into
masterfrom
stop-logging-secrets

Conversation

@jarstelfox

Copy link
Copy Markdown
Member

🤖

Every time Pulldasher starts, it writes three GitHub secrets into its log: the OAuth app secret, the API token and the webhook secret. Anyone who can read that log can read all three. This removes the line that prints them, and stops the webhook handler from logging the wrong secret a caller sent.

Summary

Nothing else on the server logs a secret. The MySQL password only goes into the database connection, and Octokit replaces the token with [REDACTED] in the errors we log.

Output with the test config, before and after

On master, loading lib/git-manager.js prints:

{
  clientId: 'test-client-id',
  secret: 'test-secret',
  callbackURL: 'http://localhost:3000/auth/github/callback',
  token: 'test-token',
  hook_secret: 'test-hook-secret'
}

A webhook call with ?secret=wrong-value then adds Invalid Hook Secret: wrong-value. On this branch the first prints nothing and the second prints only Invalid Hook Secret.

Note

Deploying this stops new copies. Logs written before the deploy still hold what was printed then.

QA

  • Run npm test on Node 24. CI only runs lint and build.

  • From the repo root, run this and confirm it prints nothing:

    CONFIG_PATH=../test/fixtures/config.js node --input-type=module -e "await import('./lib/git-manager.js'); process.exit(0)"
  • Run this and confirm it prints Invalid Hook Secret without wrong-value:

    CONFIG_PATH=../test/fixtures/config.js node --input-type=module -e "const { default: hooks } = await import('./controllers/githubHooks.js'); hooks.main({ query: { secret: 'wrong-value' } }, { status() { return this; }, send() {} }); process.exit(0)"

🤖 Generated with Claude Code

Every time the server or one of the bin/refresh-* scripts started,
lib/git-manager.js printed the whole config.github object to stdout.
That object holds the OAuth app secret, the API token and the webhook
secret. In Docker, stdout goes to the container log, so anyone who
can read that log can read all three. The line came in with 5db15a2
(lib: Convert to ESM) and reached master with #419 on 2025-03-04.
Nothing depends on that output; it looks like a debugging print that
stayed in.

The webhook handler also printed the secret a caller sent whenever it
didn't match hook_secret. That value can be a real secret as well,
such as one meant for another Pulldasher instance, or the old one
after a rotation. The handler still logs "Invalid Hook Secret", now
without the value.

Checked by loading both files with test/fixtures/config.js and
counting the fixture's secrets in stdout and stderr. Before this
change the token, the OAuth secret and the webhook secret each
printed once, and a webhook call with a wrong secret printed that
value twice. After it, all four counts are zero.

Note: this stops new copies. It doesn't remove what earlier starts
already wrote to existing logs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@djmetzle djmetzle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CR 🔏

@jarstelfox
jarstelfox merged commit 00ffa28 into master Sep 30, 2026
1 check passed
@jarstelfox
jarstelfox deleted the stop-logging-secrets branch September 30, 2026 20:20
jarstelfox added a commit that referenced this pull request Sep 30, 2026
The deployed images print GitHub secrets to their logs on every start; master stopped that, so bring it in before this branch deploys again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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