Skip to content

Fixes: Add digest length checking #405

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

Merged
merged 3 commits into from
May 11, 2023

Conversation

arthurscchan
Copy link
Contributor

@arthurscchan arthurscchan commented Mar 29, 2023

According to the ECDSASignature class, the NoneWithECDSA mode only accept a digest with maximum length of 64 bytes, using a digest longer than 64 will result in ArrayIndexOutOfBoundException when the full byte array is copied to a byte array with only 64 bytes.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=57360

Summary

Release Note

Documentation

Signed-off-by: Arthur Chan <[email protected]>
Comment on lines 46 to 48
if (artifactDigest.length > 64) {
throw new SignatureExeption("Artifact digest cannot be longer than 64 bytes for this mode");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

How is this better than the exception from signature.update(artifactDigest); ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if the check should be implemented in the downstream library instead. Of course, it is easier to sweep it under the rug here, however, it is hard to understand why we have an artificial limit of 64 here.

So I would suggest filing an issue/PR for the impl library rather than sigstore-java

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense to me. Let's make a PR there and see how it's retrieved.

Copy link
Member

Choose a reason for hiding this comment

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

Just checking in? Was there any resolution on this? Is there a PR somewhere to follow up on?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I missed this! Apologies -- @arthurscchan could you help with this one?

Copy link
Contributor

Choose a reason for hiding this comment

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

I just spoke to @arthurscchan and @AdamKorcz who said it may not be the correct choice to change upstream. @AdamKorcz could you elaborate?

Copy link
Contributor

@AdamKorcz AdamKorcz May 10, 2023

Choose a reason for hiding this comment

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

The best "upstream" place to fix this issue is at the provider level. However, this is not a suitable place to fix this issue, since there are many providers that sigstore-java users can consume. In addition, sigstore-java users can write their own providers. As such, sigstore-java is the best place to do the digest length check.

loosebazooka
loosebazooka previously approved these changes May 10, 2023
@loosebazooka
Copy link
Member

ugh sorry, not all these statuses are manually triggerable. Can you rebase it so we can get all the statuses green?

@loosebazooka
Copy link
Member

looks like this needs some manual intervention

Signed-off-by: Arthur Chan <[email protected]>
@loosebazooka loosebazooka merged commit 1e35886 into sigstore:main May 11, 2023
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