Skip to content

CI: Add cargo-audit workflow#557

Open
tnull wants to merge 4 commits intorust-bitcoin:masterfrom
tnull:2026-04-audit-ci
Open

CI: Add cargo-audit workflow#557
tnull wants to merge 4 commits intorust-bitcoin:masterfrom
tnull:2026-04-audit-ci

Conversation

@tnull
Copy link
Copy Markdown
Collaborator

@tnull tnull commented Apr 17, 2026

Run security audits against all three checked-in lock files using the official rustsec/audit-check action. Triggers on push, PRs, and daily via cron to catch newly published advisories.

Co-Authored-By: HAL 9000

@tnull tnull requested a review from tcharding as a code owner April 17, 2026 09:35
@tnull
Copy link
Copy Markdown
Collaborator Author

tnull commented Apr 17, 2026

Also bumped some dependencies, rest should be done in #556 or #536.

Copy link
Copy Markdown

@luisschwab luisschwab left a comment

Choose a reason for hiding this comment

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

ACK 2e56f00

@luisschwab
Copy link
Copy Markdown

cc @satsfy

strategy:
fail-fast: false
matrix:
lockfile: [Cargo.lock, Cargo-minimal.lock, Cargo-recent.lock]
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.

Why is Cargo.lock part of the matrix?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

against all three checked-in lock files

Yeah there should only be two. Did I commit one in electrsd accidentally or something?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ah, right, dropped it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Actually, it might make sense to add a step to generate a clean-slate Cargo.lock for this and then have the audit job check it? Otherwise we could theoretically miss advisories that don't pertain to the specific versions checked-in via Cargo-{minimal, recent}.lock, but would still be present if users would just cargo build regularly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Now added a generate-lockfile step in 52e3dad, so we don't just check our checked-in versions over and over again.

@tcharding
Copy link
Copy Markdown
Member

As it stands no-one is ever going to look at the auction run (well I definitely won't remember to do it). Can we have the action raise an issue if there are warnings? Or is that going to be too noisy? I don't have a lot of experience with cargo audit. (We do this already in rust-bitcoin for mutation testing when zombies survive.)

@luisschwab
Copy link
Copy Markdown

The GitHub bot will usually open an issue when there is a new RUSTSEC (see bitcoindevkit/bdk#2178).

@tcharding
Copy link
Copy Markdown
Member

tcharding commented Apr 18, 2026

Does that bot hit projects to use cargo audit?

@luisschwab
Copy link
Copy Markdown

Actually, I think we need to use the actions-rust-lang/audit action for it to open issues. On my personal repos I only use the bare cargo audit and it does not open any issues there.

This is bdk's audit job:

name: Audit

on:
  push:
    paths:
      # Run if workflow changes
      - '.github/workflows/audit.yml'
      # Run on changed dependencies
      - '**/Cargo.toml'
      - '**/Cargo.lock'
      # Run if the configuration file changes
      - '**/audit.toml'
  # Rerun periodically to pick up new advisories
  schedule:
    - cron: '0 0 * * *' # Nightly
  # Run manually
  workflow_dispatch:

jobs:
  audit:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      issues: write
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false
      - uses: actions-rust-lang/audit@v1
        name: Audit Rust Dependencies

I could be talking out of my ass, I'm not certain about this.

@tcharding
Copy link
Copy Markdown
Member

Sounds legit :)

@tnull tnull force-pushed the 2026-04-audit-ci branch 3 times, most recently from c425756 to 2dc1257 Compare April 20, 2026 07:01
@tnull
Copy link
Copy Markdown
Collaborator Author

tnull commented Apr 20, 2026

As it stands no-one is ever going to look at the auction run (well I definitely won't remember to do it). Can we have the action raise an issue if there are warnings? Or is that going to be too noisy? I don't have a lot of experience with cargo audit. (We do this already in rust-bitcoin for mutation testing when zombies survive.)

This will already do this, hence the issues: write permissions. See for example LDK Node where we use it (https://github.com/lightningdevkit/ldk-node/blob/main/.github/workflows/audit.yml), example issue: lightningdevkit/ldk-node#836.

Actually, I think we need to use the actions-rust-lang/audit action for it to open issues. On my personal repos I only use the bare cargo audit and it does not open any issues there.

No, audit-check is definitely sufficient, but it will only open issues via the cron-scheduled jobs:

"The action does not raise issues when it is not triggered from a "cron" scheduled workflow." (see https://github.com/rustsec/audit-check#granular-permissions)

If we want to validate that it works as expected, we could split out the fixes / bump commits to a second PR and first ensure the job opens an issue for the advisories found. Should we do that?

tnull added 3 commits April 20, 2026 09:19
Run security audits against all three checked-in lock files using the
official rustsec/audit-check action. Triggers on push, PRs, and daily
via cron to catch newly published advisories.

Co-Authored-By: HAL 9000
Signed-off-by: Elias Rohrer <dev@tnull.de>
Addresses RUSTSEC-2026-0007 (bytes), RUSTSEC-2026-0067/0068 (tar),
and RUSTSEC-2026-0097 (rand).

Co-Authored-By: HAL 9000
Signed-off-by: Elias Rohrer <dev@tnull.de>
Bump ring to 0.17.14 to address RUSTSEC-2025-0009.

Co-Authored-By: HAL 9000
Signed-off-by: Elias Rohrer <dev@tnull.de>
@tnull tnull force-pushed the 2026-04-audit-ci branch from 2dc1257 to 1880501 Compare April 20, 2026 07:19
The checked-in Cargo-minimal.lock and Cargo-recent.lock are only as
fresh as their last manual update, so advisories affecting versions
that the resolver would pick right now can slip through between lock
refreshes. Add a matrix leg that runs `cargo generate-lockfile` before
auditing, giving us clean-slate coverage on every scheduled run.

Co-Authored-By: HAL 9000
Signed-off-by: Elias Rohrer <dev@tnull.de>
@luisschwab
Copy link
Copy Markdown

@tcharding can you re-trigger the failing job?

Copy link
Copy Markdown

@luisschwab luisschwab left a comment

Choose a reason for hiding this comment

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

ACK 52e3dad

Copy link
Copy Markdown
Collaborator

@jamillambert jamillambert left a comment

Choose a reason for hiding this comment

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

ACK 52e3dad

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.

5 participants