chore: scan CI logs for secrets before uploading them as artifacts - #2279
Open
nicosampler wants to merge 2 commits into
Open
chore: scan CI logs for secrets before uploading them as artifacts#2279nicosampler wants to merge 2 commits into
nicosampler wants to merge 2 commits into
Conversation
Artifacts of a public repository can be downloaded by anyone, so a credential printed into a log is public once the log is uploaded. Deleting the artifact afterwards does not undo that. Runs gitleaks over a file or directory and fails when it finds something, with --redact so the finding does not leak the value into the public job log. gitleaks is pinned by version and SHA-256 so a replaced release asset is never executed. Signed-off-by: nicosampler <[email protected]>
Gates the six log-upload steps on the scan having succeeded, so a run that leaks stops before publishing instead of after. Signed-off-by: nicosampler <[email protected]>
nicosampler
force-pushed
the
nicosampler/1892-ci-scan-secrets-in-logs
branch
from
August 12, 2026 18:07
08af44a to
30f9bbe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1892
Why
Artifacts of a public repo can be downloaded by anyone. So a credential printed
into a log is public as soon as the log is uploaded, and deleting the artifact
later does not undo it. Four workflows upload logs today, and nothing checks what
is inside them.
What
New composite action
.github/actions/scan_logs_for_secretsruns gitleaks over afile or directory and fails when it finds something. The six log-upload steps now
depend on it, so a run that leaks stops before publishing instead of after.
--redactmeans a finding reports the file, line and rule, never the value.upstream, it still gets downloaded but never runs.
Why gitleaks and not the script from the issue
The check the issue points at is two regexes:
secret=,token=,private-key=or
password=followed by a value, and JWTs. Copying those two lines would beeasy, but that is all the coverage you get. It has also been deleted from that
repo (canton-network/splice-shared-gha@2282d1c), so there is nothing to reuse.
gitleaks catches those plus GitHub PATs, AWS keys, PEM blocks and Slack webhooks,
with no rules in this repo to maintain.
The two also differ on what happens when something is found. The script hides the
value with
sedand uploads the log anyway. This action fails the job and skipsthe upload, so the value has to be fixed where it is printed.
Verified
workflows run on
ubuntu-latest, solinux_x64is the right build.build.ymlrun, 60k lines, soit should not start failing builds on noise. The gateway already redacts
(
"clientSecret": "*****"); this catches what that misses.webhooks and
keyword=valueassignments.Still to do
The only way to be sure this works is to plant a secret in a log on purpose, push
that commit, and check that CI turns red, that the error message hides the value,
and that no log artifact shows up on the run. That commit should be reverted once
the test is done. We cannot run this here, so it is up to the reviewer.
Note that
stress-tests.ymlandexamples-under-stress.ymlonly run on manualdispatch, so this PR never exercises them.
Limitations
Weak values are not caught.
check-logs.shflags anysecret=,token=,private-key=orpassword=whatever the value is. gitleaks needs roughly 12characters and high entropy, so
password=hunter2passes here and would havefailed there.
Lowering the threshold means adding a
.gitleaks.tomlwith an allowlist to keepcurrent. The reference script needs exactly that, including a
sedthat hides aknown
secret=test. Worth doing if the need shows up.Playwright reports are not covered. They are still uploaded unscanned, and
their trace files do contain
Authorization: Bearer <JWT>. Those are local devtokens (
{"sub":"ledger-api-user"}, HS256, noexp), so nothing real is exposedtoday.
Adding this action to those paths would give a false sense of safety. Playwright
saves its traces as
.zipfiles and gitleaks does not look inside archives. On a15 MB report it reads only the 2 MB that is not compressed and finds nothing,
while the tokens sit in the zips. Unzipping one by hand turned up 187 JWTs. This
deserves its own issue if these leaks are considered unsafe, or if any of these
jobs could ever run with real credentials.
This fails closed. If the gitleaks download fails, the logs are not uploaded.
Worth knowing when a red run shows no log artifact.