-
Notifications
You must be signed in to change notification settings - Fork 554
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
Find all valid entries in verify-blob #1673
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,5 @@ | |
|
||
bin* | ||
dist/ | ||
|
||
test/verify-experimental* |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright 2021 The Sigstore Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# This test checks that verify-blob will iterate over all entries and check for at least one valid entry before erroring out | ||
# This is to prevent verify-blob from only checking the most recent entry, which could result | ||
# in a "denial of service" type attack if someone signs a piece of software | ||
# with their own certificate which doesn't chain up to Sigstore | ||
|
||
set -ex | ||
|
||
export COSIGN_EXPERIMENTAL=1 | ||
|
||
echo "Creating a unique blob" | ||
BLOB=verify-experimental-blob | ||
date > $BLOB | ||
|
||
echo "Sign the blob with cosign first and upload to rekor" | ||
SIG=$(cosign sign-blob $BLOB) | ||
|
||
echo "Verifying ..." | ||
cosign verify-blob -signature $SIG $BLOB | ||
|
||
# Now, sign the blob with a self-signed certificate and upload to rekor | ||
SIG_FILE=verify-experimental-signature | ||
openssl dgst -sha256 -sign testdata/test_blob_private_key -out $SIG_FILE $BLOB | ||
openssl dgst -sha256 -verify testdata/test_blob_public_key -signature $SIG_FILE $BLOB | ||
|
||
SHA256HASH=$(sha256sum $BLOB | cut -f1 -d' ') | ||
|
||
SIGNATURE=$(cat $SIG_FILE | base64) | ||
echo "Signature: $SIGNATURE" | ||
|
||
CERT=$(cat testdata/test_blob_cert.pem | base64) | ||
echo "Cert: $CERT" | ||
|
||
JSON_BODY_FILE=verify-experimental-blob-http-body.json | ||
cat <<EOF > $JSON_BODY_FILE | ||
{ | ||
"apiVersion": "0.0.1", | ||
"spec": { | ||
"data": { | ||
"hash": { | ||
"algorithm": "sha256", | ||
"value": "$SHA256HASH" | ||
} | ||
}, | ||
"signature": { | ||
"content": "$SIGNATURE", | ||
"publicKey": { | ||
"content": "$CERT" | ||
} | ||
} | ||
}, | ||
"kind": "hashedrekord" | ||
} | ||
EOF | ||
|
||
curl -X POST https://rekor.sigstore.dev/api/v1/log/entries -H 'Content-Type: application/json' -d @$JSON_BODY_FILE | ||
|
||
# Verifying should still work | ||
echo "Verifying ..." | ||
cosign verify-blob --signature $SIG $BLOB |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIB9jCCAZwCCQDmJAPXiurv9jAKBggqhkjOPQQDAjCBgjELMAkGA1UEBhMCVVMx | ||
CzAJBgNVBAgMAkNBMQswCQYDVQQHDAJTRjEQMA4GA1UECgwHQ29tcGFueTENMAsG | ||
A1UECwwEVW5pdDEYMBYGA1UEAwwPd3d3LmV4YW1wbGUub3JnMR4wHAYJKoZIhvcN | ||
AQkBFg9lbWFpbEBlbWFpbC5jb20wHhcNMjIwMzI4MTgwNDIwWhcNMjIwNDI3MTgw | ||
NDIwWjCBgjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJTRjEQ | ||
MA4GA1UECgwHQ29tcGFueTENMAsGA1UECwwEVW5pdDEYMBYGA1UEAwwPd3d3LmV4 | ||
YW1wbGUub3JnMR4wHAYJKoZIhvcNAQkBFg9lbWFpbEBlbWFpbC5jb20wWTATBgcq | ||
hkjOPQIBBggqhkjOPQMBBwNCAAR1Q4hB1jtagrdsVxygtDa/rli00U7n/1I/NSw8 | ||
yoMRQ+MOAjRhg3gtcV0tha34L6150qJirQHbfocsao8X6wFmMAoGCCqGSM49BAMC | ||
A0gAMEUCIQDkZ4ZmFOK2Ze+znScge1JidTRzxNxCLbrdfc5yEJia2QIgCEjIY6Zo | ||
QUwiyuC3ll5a9GDc4swfguZq9kOFX9bD0XQ= | ||
-----END CERTIFICATE----- |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-----BEGIN EC PARAMETERS----- | ||
BggqhkjOPQMBBw== | ||
-----END EC PARAMETERS----- | ||
-----BEGIN EC PRIVATE KEY----- | ||
MHcCAQEEIMJRdxVQ7AH6z1BlE9ucEMSAQhY431IFHe0oVCH7Iw49oAoGCCqGSM49 | ||
AwEHoUQDQgAEdUOIQdY7WoK3bFccoLQ2v65YtNFO5/9SPzUsPMqDEUPjDgI0YYN4 | ||
LXFdLYWt+C+tedKiYq0B236HLGqPF+sBZg== | ||
-----END EC PRIVATE KEY----- |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-----BEGIN PUBLIC KEY----- | ||
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEdUOIQdY7WoK3bFccoLQ2v65YtNFO | ||
5/9SPzUsPMqDEUPjDgI0YYN4LXFdLYWt+C+tedKiYq0B236HLGqPF+sBZg== | ||
-----END PUBLIC KEY----- |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI inside this we make another extraneous call to Rekor to get the TLOG entry UUID (
cosign/cmd/cosign/cli/verify/verify_blob.go
Line 326 in e2017af
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @asraa !