Skip to content

Port contents of Documentation/PackageSecurity.md to DocC #8726

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

bripeticca
Copy link
Contributor

Fixes #8591

Ports the contents of Documentation/PackageSecurity.md to our DocC catalog in Sources/PackageManagerDocs/PackageSecurity.md.

@bripeticca
Copy link
Contributor Author

@swift-ci please test

@bripeticca
Copy link
Contributor Author

@swift-ci please test

@bripeticca
Copy link
Contributor Author

@swift-ci please test windows

@heckj
Copy link
Member

heckj commented May 28, 2025

@swift-ci please test windows platform self hosted

@@ -0,0 +1,50 @@
# Package Security

Learn about the security features that SwiftPM implements.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Learn about the security features that SwiftPM implements.
Learn about the security features that the package manager implements.

(I've been taking to removing SwiftPM and replacing it with "package manager")


## Trust on First Use

SwiftPM records **fingerprints** of downloaded package versions so that
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
SwiftPM records **fingerprints** of downloaded package versions so that
Package manager records **fingerprints** of downloaded package versions so that

SwiftPM records **fingerprints** of downloaded package versions so that
it can perform [trust-on-first-use](https://en.wikipedia.org/wiki/Trust_on_first_use)
(TOFU).
That is, when a package version is downloaded for the first time, SwiftPM trusts that
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
That is, when a package version is downloaded for the first time, SwiftPM trusts that
That is, when a package version is downloaded for the first time, the package manager trusts that

it has downloaded the correct contents and requires subsequent downloads of the same
package version to have the same fingerprint.
If the fingerprint changes, it might be an indicator that the package has been
compromised and SwiftPM will either warn or return an error.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
compromised and SwiftPM will either warn or return an error.
compromised and the package manager either warns or returns an error.
Control the choice of warning or error using the build option `--resolver-fingerprint-checking`, which defaults to `strict`.
Set the value to `warn` to not error on a mismatched fingerprint.

| Git repository | Git hash of the revision |
| Package registry | Checksum of the source archive |

All version fingerprints of a package are kept in a single file
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
All version fingerprints of a package are kept in a single file
The package manager keeps version fingerprints for each package in a file


All version fingerprints of a package are kept in a single file
under the `~/.swiftpm/security/fingerprints` directory.
- For a Git repository package, the fingerprint filename takes the form of `{PACKAGE_NAME}-{REPOSITORY_URL_HASH}.json` (e.g., `LinkedList-5ddbcf15.json`).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- For a Git repository package, the fingerprint filename takes the form of `{PACKAGE_NAME}-{REPOSITORY_URL_HASH}.json` (e.g., `LinkedList-5ddbcf15.json`).
- For a Git repository package, the fingerprint filename takes the form of `{PACKAGE_NAME}-{REPOSITORY_URL_HASH}.json` (such as `LinkedList-5ddbcf15.json`).

All version fingerprints of a package are kept in a single file
under the `~/.swiftpm/security/fingerprints` directory.
- For a Git repository package, the fingerprint filename takes the form of `{PACKAGE_NAME}-{REPOSITORY_URL_HASH}.json` (e.g., `LinkedList-5ddbcf15.json`).
- For a registry package, the fingerprint filename takes the form of `{PACKAGE_ID}.json` (e.g., `mona.LinkedList.json`).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- For a registry package, the fingerprint filename takes the form of `{PACKAGE_ID}.json` (e.g., `mona.LinkedList.json`).
- For a registry package, the fingerprint filename takes the form of `{PACKAGE_ID}.json` (such as `mona.LinkedList.json`).

under the `~/.swiftpm/security/fingerprints` directory.
- For a Git repository package, the fingerprint filename takes the form of `{PACKAGE_NAME}-{REPOSITORY_URL_HASH}.json` (e.g., `LinkedList-5ddbcf15.json`).
- For a registry package, the fingerprint filename takes the form of `{PACKAGE_ID}.json` (e.g., `mona.LinkedList.json`).

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
For packages retrieved from a registry, the package manager expects all registries to provide consistent fingerprints for packages they host.
If registries have conflicting fingerprints, package manager reports that as an error.

- For a registry package, the fingerprint filename takes the form of `{PACKAGE_ID}.json` (e.g., `mona.LinkedList.json`).


### Using fingerprints for TOFU
Copy link
Member

Choose a reason for hiding this comment

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

Everything from line 30 (heading included) is replicated content from above - I made some suggestions to cherry pick a few details in the content above, and I think everything below can be deleted. Give it a read through and verify though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate documentation for Package Security to DocC
2 participants