Skip to content

Commit a68ad6d

Browse files
mac-chaffeedi
andauthored
Add summaries for the security models of attestations and trusted publishing (#17242)
* Add summaries for the security models of attestations and trusted publishers Signed-off-by: Mac Chaffee <[email protected]> * Apply suggestions from code review * Switch to non-walled link * Clarify short/long-lived token risks * Update docs/user/trusted-publishers/security-model.md --------- Signed-off-by: Mac Chaffee <[email protected]> Co-authored-by: Dustin Ingram <[email protected]>
1 parent dbd05f6 commit a68ad6d

File tree

2 files changed

+87
-29
lines changed

2 files changed

+87
-29
lines changed

docs/user/attestations/security-model.md

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ title: Security Model and Considerations
44

55
# Security model and considerations
66

7+
Since attestations are a framework for asserting certain facts about a package,
8+
the security model of attestations depends on which types of facts are being
9+
asserted.
10+
11+
The most basic type of attestation (the type enabled by default in
12+
[`pypa/gh-action-pypi-publish`][gh-action-pypi-publish]) asserts that the
13+
project was published by an authorized publisher such as a particular CI
14+
provider in a particular code repository.
15+
16+
This type of attestation has two main purposes:
17+
18+
- It protects against modification of a project *after* it was built,
19+
such as while it is stored in a package index or mirror.
20+
- It allows verifying parties to observe *changes* to the project's Trusted Publisher.
21+
For example, a verifying party might observe that a project's new releases
22+
are coming from a different Trusted Publisher, indicating that control
23+
of the project may have changed hands maliciously.
24+
25+
More advanced types of attestations can assert more things about the package
26+
such as whether it was tampered with *before* it was built, but these
27+
attestations require specialized build processes and are rarer as a result. See
28+
"[What about reproducible builds?]" in the SLSA FAQ.
29+
730
## General considerations
831

932
PyPI's support for attestations is built on top of a combination
@@ -14,27 +37,27 @@ See below for security considerations for each.
1437

1538
!!! note
1639

17-
TL;DR: An attestation will tell you **who** produced a
18-
PyPI package, but not **whether** you should trust them.
40+
TL;DR: An attestation will tell you **where** a PyPI package came from, but
41+
not **whether** you should trust it.
1942

2043
Like with all signing schemes, it's tempting to treat the *presence* of
2144
an attestation as proof of a package's *trustworthiness*.
2245

23-
However, this is **not** what an attestation (or any kind of signature)
24-
conveys. At its core, a valid signature for some identity conveys a
25-
proof of **authenticity**: if the signature is verifiable against a key,
26-
then we know that the identity that controls that key produced the signature
27-
and is saying *something* about the signed-over data.
46+
However, this is **not** what an attestation (or any kind of signature) conveys.
47+
At its core, a valid signature for an identity on a package conveys a proof of
48+
access to that identity while the package was built.
2849

29-
In other words: a valid signature asserts **authenticity**, but it does **not**
30-
tell the verifying party (e.g., a user installing packages from PyPI) **whether**
31-
they should trust the identity that holds the key.
50+
In other words: a valid signature does **not** tell the verifying party (e.g., a
51+
user installing packages from PyPI) **whether** they should trust the identity
52+
that holds the key or whether they should trust that malicious/vulnerable code
53+
was added before or during the build.
3254

3355
As a concrete example: PyPI serves `sampleproject-4.0.0.tar.gz`, which is
3456
[attested] by [pypa/sampleproject] on GitHub. This is a proof that
35-
`sampleproject-4.0.0.tar.gz` is authentic for that identity, but it does **not**
36-
tell the user **whether** they should trust [pypa/sampleproject]. To determine
37-
trust, the user *must* make a trust decision about [pypa/sampleproject].
57+
`sampleproject-4.0.0.tar.gz` came from that identity unmodified, but it does
58+
**not** tell the user **whether** they should trust [pypa/sampleproject]. To
59+
determine trust, the user *must* make a trust decision about
60+
[pypa/sampleproject].
3861

3962
This trust decision can have a time dimension: a user might decide to trust
4063
[pypa/sampleproject] because it was the first identity seen for the
@@ -116,6 +139,10 @@ PyPI's attestations feature makes full use of these trust-reduction techniques:
116139
attestations are not considered verified unless they include an inclusion proof
117140
from Rekor, as well as an inclusion proof from Fulcio's CT log.
118141

142+
[gh-action-pypi-publish]: https://github.com/pypa/gh-action-pypi-publish
143+
144+
[What about reproducible builds?]: https://slsa.dev/spec/v1.0/faq#q-what-about-reproducible-builds
145+
119146
[Trusted Publishing]: /trusted-publishers/
120147

121148
[Sigstore's "keyless signing"]: https://docs.sigstore.dev/cosign/signing/overview/

docs/user/trusted-publishers/security-model.md

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,50 @@ title: Security Model and Considerations
44

55
# Security model and considerations
66

7-
## General considerations
8-
9-
While more secure than passwords and long-lived API tokens, OIDC publishing
10-
is not a panacea. In particular:
11-
12-
* Short-lived API tokens are still sensitive material, and should not be
13-
disclosed (ideally not at all, but certainly not before they expire).
14-
15-
* OIDC tokens themselves are sensitive material, and should not be disclosed.
16-
OIDC tokens are also short-lived, but an attacker who successfully intercepts
17-
one can mint API tokens against it for as long as it lives.
7+
Trusted Publishing is primarily designed to be a more secure alternative to
8+
the long-lived API tokens that have traditionally been used for publishing to
9+
PyPI.
10+
11+
In recent years, theft of credentials such as API tokens has [played a major
12+
role in cyber attacks]. The reason for this is the unfortunate reality that
13+
managing credentials can be complicated and risky. Trusted Publishing reduces
14+
this risk by using short-lived tokens instead of long-lived tokens. Short-lived
15+
tokens are less likely to be misplaced, leaked in logs, or stolen by malware
16+
since they don't have to be stored. Additionally, if short-lived tokens are
17+
leaked, they only give attackers a narrow time window to exploit the leaked
18+
token, which minimizes the potential damage.
19+
20+
However, it is important to still be aware of the kinds of risks that
21+
Trusted Publishing does not cover. You should think of Trusted Publishing as one
22+
tool in the toolbelt for securing packages.
1823

19-
* Configuring a Trusted Publisher means establishing trust in a particular piece
20-
of external state (such as a GitHub Actions workflow); that state **must not**
21-
be controllable by untrusted parties.
24+
## General considerations
2225

23-
In summary: treat your Trusted Publishers *as if* they were API tokens. If you
26+
* Trusted Publishing uses short-lived API tokens that expire
27+
no more than 15 minutes after the OIDC flow that authorizes them.
28+
Just like normal API authentication, Trusted Publishing
29+
does not assert the safety of the code or the trustworthiness
30+
of its authors.
31+
32+
* Trusted Publishing does not address whether the package has been modified
33+
before or after it was built. [Attestations] can address those risks.
34+
35+
* Short-lived API tokens are sensitive material that must be protected from
36+
getting stolen or leaked.
37+
38+
* OIDC tokens themselves are also sensitive material that must be protected
39+
from getting stolen or leaked. OIDC tokens expire quickly, but an attacker who
40+
successfully intercepts one can use it to generate API tokens until it
41+
expires.
42+
43+
* Configuring a Trusted Publisher means trusting an identity provider (IdP),
44+
such as GitHub Actions. Trusted Publishing relies on the integrity of that
45+
IdP and the actors that are authorized to use it. In practice, this means
46+
that users of Trusted Publishing must protect and secure the CI/CD workflows
47+
that they register as Trusted Publishers, as weaknesses in those workflows
48+
can be equivalent to credential compromise.
49+
50+
In summary: treat your Trusted Publishers *as if* they are API tokens. If you
2451
wouldn't let a user or piece of code access your API token, then they shouldn't
2552
be able to invoke your Trusted Publisher.
2653

@@ -147,7 +174,7 @@ own security model and considerations.
147174
When using Trusted Publishing with Google Cloud, you must trust the service account
148175
and _any service which uses it as the default ephemeral identity_.
149176

150-
Specifically, it is not recommened to configure the [default service
177+
Specifically, it is not recommended to configure the [default service
151178
accounts](https://cloud.google.com/iam/docs/service-account-types#default), as
152179
they are provided by default to every service when they are created.
153180

@@ -258,6 +285,10 @@ own security model and considerations.
258285
access the OIDC token to a bare minimum. This prevents both accidental
259286
and malicious disclosure.
260287

288+
[played a major role in cyber attacks]: https://therecord.media/cisa-cyberattacks-using-valid-credentials
289+
290+
[Attestations]: /attestations/
291+
261292
[fundamentally dangerous]: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
262293

263294
[Use a dedicated environment]: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment

0 commit comments

Comments
 (0)