Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: allow DSSE verification #1015

Merged
merged 12 commits into from
May 16, 2024
Merged

cli: allow DSSE verification #1015

merged 12 commits into from
May 16, 2024

Conversation

woodruffw
Copy link
Member

@woodruffw woodruffw commented May 13, 2024

This allows for a very limited form of DSSE verification via the sigstore CLI. In particular, it allows a DSSE-containing bundle to be verified, but only if:

  • The DSSE payload is JSON;
  • The JSON is an in-toto statement;
  • The in-toto statement has at least one subject matching the input file's digest.

This limited form is compatible with what GitHub Artifact Attestations is doing and, in particular, is compatible with how gh attestation verify behaves.

WIP while I clean things up a little.

Closes #999.

Closes #780.

Signed-off-by: William Woodruff <william@trailofbits.com>
@woodruffw woodruffw requested a review from di May 13, 2024 20:04
@woodruffw woodruffw self-assigned this May 13, 2024
sigstore/_cli.py Outdated
Comment on lines 830 to 833
if not stmt._matches_digest(digest):
raise VerificationError(
f"in-toto statement has no subject for digest {digest.digest.hex()}"
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Flagging: this is consistent with what gh attestation verify does, but I think it's potentially susceptible to misuse: in most contexts you also care about the name assigned to each subject, to prevent domain confusion attacks (e.g. where you request foo==1.2.3, but the attacker gives you an old, vulnerable foo==1.0.0 with a valid signature for that older version).

The argument in this case for not doing that is that gh attestation verify doesn't bother to do it either, plus the pre-existing hashedrekord-based verification can't do it (since it was only over the input bytes, not the input name). So as-is there's no degradation in the security model, but it's worth highlighting and thinking about in the future.

Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
di
di previously approved these changes May 13, 2024
sigstore/_cli.py Outdated Show resolved Hide resolved
Co-authored-by: Dustin Ingram <di@users.noreply.github.com>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
@woodruffw woodruffw marked this pull request as ready for review May 13, 2024 21:52
@woodruffw woodruffw added component:cli CLI components component:verification Core verification functionality labels May 13, 2024
@woodruffw woodruffw requested a review from di May 13, 2024 21:54
@woodruffw woodruffw requested a review from jku May 14, 2024 12:52
Copy link
Member

@jku jku left a comment

Choose a reason for hiding this comment

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

DSSE parts look fine. The verify github change seems a bit fishy in that we no longer make sure the issuer is github -- maybe we should change policy.Identity to accept identity: str | None, issuer: str as args and then use that in _verify_github, or alternatively have a separate policy.Issuer that only checks the issuer?

sigstore/_cli.py Outdated Show resolved Hide resolved
Signed-off-by: William Woodruff <william@trailofbits.com>
@woodruffw
Copy link
Member Author

DSSE parts look fine. The verify github change seems a bit fishy in that we no longer make sure the issuer is github -- maybe we should change policy.Identity to accept identity: str | None, issuer: str as args and then use that in _verify_github, or alternatively have a separate policy.Issuer that only checks the issuer?

Ah yeah, good catch -- I think we can re-use the already existing policy.OIDCIssuer for this 🙂

Signed-off-by: William Woodruff <william@trailofbits.com>
@woodruffw woodruffw requested a review from jku May 14, 2024 14:23
sigstore/_cli.py Outdated
Comment on lines 856 to 861
# No matter what the user configures above, we require the OIDC issuer to
# be GitHub Actions. We add this below the check above, since it doesn't
# constitute a sufficient policy check on its own.
inner_policies.append(
policy.OIDCIssuer("https://token.actions.githubusercontent.com")
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Flagging: right now we allow any of the CLI options to be a "sufficient" option for verification with sigstore verify github, which is potentially misleading or insufficient.

For example, a user could do sigstore verify github ... --name foo, which would only check the workflow's name and allow any GitHub user/org and repo, which probably isn't what they intended.

Given that, should be restrict this to a few sufficient combinations? Some ideas:

  • --cert-identity, as before, to bind the full user/repo and workflow path
  • --repository, to bind the user/repo
  • Others, from the "V2" extensions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Tweaked this with 41d3fc9 -- we now require --cert-identity OR --repository, which should be misuse-resistant without being burdensome.

Copy link
Member Author

Choose a reason for hiding this comment

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

(This is more or less consistent with what gh attestation verify does, although they also allow just --owner)

Copy link
Member

Choose a reason for hiding this comment

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

41d3fc9 seems quite reasonable.

Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Copy link
Member

@jku jku left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for all the work on this. Reasoning for required options seems good to me.

Suggestions for docs (could file additional issues for these):

  • The README examples of github verification are now not completely up to date: we should add a --repository example (maybe as the first one)
  • there is no "body text" in sigstore verify github --help: A description that mentions the required flags would make sense

inner_policies.append(
policy.Identity(
identity=args.cert_identity,
# We always explicitly check the issuer below, so configuring
Copy link
Member

Choose a reason for hiding this comment

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

nit: "below" here and "above" a few lines earlier are now a bit confusing

@woodruffw woodruffw merged commit dbab104 into main May 16, 2024
25 checks passed
@woodruffw woodruffw deleted the ww/dsse-in-cli branch May 16, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:cli CLI components component:verification Core verification functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose DSSE verification in the CLI --cert-identity should be optional on sigstore verify github
4 participants