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

Fix: Create a static copy of signatures as part of verification. #2287

Merged
merged 1 commit into from Sep 27, 2022

Conversation

mattmoor
Copy link
Member

@mattmoor mattmoor commented Sep 27, 2022

🐛 As part of verifying signatures and annotations create copies of what we are downloading to avoid later calls to Payload() redownloading the signature blob.

Examining trace data for policy-controller downstream, I observed that the same signature blob data was being fetched three times as part of verification. I believe for attestations this may be even worse because we have an additional call to Payload() where we parse out the contents of the attestation's predicate for policy evaluation.

This change eagerly fetches the signature metadata and stores it in a clone via static.Copy. This clone is what we verify, and if it fails verification is it immediately discarded. However, if it passes verification this clone is returned as one of the "verified signatures" that the downstream logic can now access without refetching data from the registry.

UPDATE: I have confirmed downstream by manually vendoring this in that the redundant blob fetches go away and the admission webhook requests are noticeably faster. It isn't quite 3x because of other overheads, but it is pretty considerable.

/kind bug

Signed-off-by: Matt Moore mattmoor@chainguard.dev

Release Note

Speed up some of the verification methods by eliminating redundant fetches of the signature blob data from the registry using a temporary in-memory copy.

Documentation

🐛 As part of verifying signatures and annotations create copies of what we are downloading to avoid later calls to `Payload()` redownloading the signature blob.

Examining trace data for policy-controller downstream, I observed that the same signature blob data was being fetched three times as part of verification.  I believe for attestations this may be even worse because we have an
additional call to `Payload()` where we parse out the contents of the attestation's predicate for policy evaluation.

This change eagerly fetches the signature metadata and stores it in a clone via `static.Copy`.  This clone is what we verify, and if it fails verification is it immediately discarded.  However, if it passes verification this clone is
returned as one of the "verified signatures" that the downstream logic can now access without refetching data from the registry.

/kind bug

Signed-off-by: Matt Moore <mattmoor@chainguard.dev>
@codecov-commenter
Copy link

codecov-commenter commented Sep 27, 2022

Codecov Report

Merging #2287 (17156ca) into main (d720f04) will decrease coverage by 0.20%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main    #2287      +/-   ##
==========================================
- Coverage   29.02%   28.82%   -0.21%     
==========================================
  Files         131      131              
  Lines        7872     7928      +56     
==========================================
  Hits         2285     2285              
- Misses       5275     5331      +56     
  Partials      312      312              
Impacted Files Coverage Δ
pkg/cosign/verify.go 31.71% <0.00%> (-0.37%) ⬇️
pkg/oci/static/signature.go 50.00% <0.00%> (-44.45%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@mattmoor mattmoor changed the title [WIP] Fix: Create a static copy of signatures as part of verification. Fix: Create a static copy of signatures as part of verification. Sep 27, 2022
@mattmoor mattmoor enabled auto-merge (squash) September 27, 2022 04:58
@mattmoor mattmoor merged commit 6486a08 into sigstore:main Sep 27, 2022
@github-actions github-actions bot added this to the v1.13.0 milestone Sep 27, 2022
@mattmoor mattmoor deleted the copy-signatures branch September 27, 2022 15:02
jeff-mccoy pushed a commit to defenseunicorns/zarf that referenced this pull request Oct 7, 2022
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/sigstore/cosign](https://togithub.com/sigstore/cosign) |
require | minor | `v1.12.1` -> `v1.13.0` |

---

### Release Notes

<details>
<summary>sigstore/cosign</summary>

###
[`v1.13.0`](https://togithub.com/sigstore/cosign/blob/HEAD/CHANGELOG.md#v1130)

[Compare
Source](https://togithub.com/sigstore/cosign/compare/v1.12.1...v1.13.0)

> # Highlights
>
> - For users who have deployed a private instance of Fulcio release
v0.6.x and issue certificates with the Username identity, you will need
to upgrade to use this version."

#### Enhancements

- Add support for Fulcio username identity in SAN
([sigstore/cosign#2291)
- Data race in FetchSignaturesForReference
([sigstore/cosign#2283)
- Check error on chain verification failure
([sigstore/cosign#2284)
- feat: improve the verification message
([sigstore/cosign#2268)
- feat: use stdin as an input for predicate
([sigstore/cosign#2269)

#### Bug Fixes

- fix: make tlog entry lookups for online verification shard-aware
([sigstore/cosign#2297)
- Fix: Create a static copy of signatures as part of verification.
([sigstore/cosign#2287)
- Fix: Remove an extra registry request from verification path.
([sigstore/cosign#2285)
- fix pivtool generate key touch policy
([sigstore/cosign#2282)

#### Others

- use scaffolding 0.4.8 for tests.
([sigstore/cosign#2280)

#### Contributors

-   Asra Ali ([@&#8203;asraa](https://togithub.com/asraa))
- Batuhan Apaydın
([@&#8203;developer-guy](https://togithub.com/developer-guy))
- Carlos Tadeu Panato Junior
([@&#8203;cpanato](https://togithub.com/cpanato))
- Hayden Blauzvern
([@&#8203;haydentherapper](https://togithub.com/haydentherapper))
-   Matt Moore ([@&#8203;mattmoor](https://togithub.com/mattmoor))
-   Ross Tannenbaum ([@&#8203;RTann](https://togithub.com/RTann))
-   Ville Aikas ([@&#8203;vaikas](https://togithub.com/vaikas))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click
this checkbox.

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/defenseunicorns/zarf).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMjIuMyIsInVwZGF0ZWRJblZlciI6IjMyLjIyMi4zIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Noxsios pushed a commit to defenseunicorns/zarf that referenced this pull request Mar 8, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/sigstore/cosign](https://togithub.com/sigstore/cosign) |
require | minor | `v1.12.1` -> `v1.13.0` |

---

### Release Notes

<details>
<summary>sigstore/cosign</summary>

###
[`v1.13.0`](https://togithub.com/sigstore/cosign/blob/HEAD/CHANGELOG.md#v1130)

[Compare
Source](https://togithub.com/sigstore/cosign/compare/v1.12.1...v1.13.0)

> # Highlights
>
> - For users who have deployed a private instance of Fulcio release
v0.6.x and issue certificates with the Username identity, you will need
to upgrade to use this version."

#### Enhancements

- Add support for Fulcio username identity in SAN
([sigstore/cosign#2291)
- Data race in FetchSignaturesForReference
([sigstore/cosign#2283)
- Check error on chain verification failure
([sigstore/cosign#2284)
- feat: improve the verification message
([sigstore/cosign#2268)
- feat: use stdin as an input for predicate
([sigstore/cosign#2269)

#### Bug Fixes

- fix: make tlog entry lookups for online verification shard-aware
([sigstore/cosign#2297)
- Fix: Create a static copy of signatures as part of verification.
([sigstore/cosign#2287)
- Fix: Remove an extra registry request from verification path.
([sigstore/cosign#2285)
- fix pivtool generate key touch policy
([sigstore/cosign#2282)

#### Others

- use scaffolding 0.4.8 for tests.
([sigstore/cosign#2280)

#### Contributors

-   Asra Ali ([@&#8203;asraa](https://togithub.com/asraa))
- Batuhan Apaydın
([@&#8203;developer-guy](https://togithub.com/developer-guy))
- Carlos Tadeu Panato Junior
([@&#8203;cpanato](https://togithub.com/cpanato))
- Hayden Blauzvern
([@&#8203;haydentherapper](https://togithub.com/haydentherapper))
-   Matt Moore ([@&#8203;mattmoor](https://togithub.com/mattmoor))
-   Ross Tannenbaum ([@&#8203;RTann](https://togithub.com/RTann))
-   Ville Aikas ([@&#8203;vaikas](https://togithub.com/vaikas))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click
this checkbox.

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/defenseunicorns/zarf).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMjIuMyIsInVwZGF0ZWRJblZlciI6IjMyLjIyMi4zIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

None yet

3 participants