Commit Graph

400 Commits

Author SHA1 Message Date
Brian Smith 2dae2124f5 wip 2024-02-18 14:49:11 -08:00
Brian Smith 94e6e88ed9 CI: Use free macOS runners for aarch64-apple-darwin jobs. 2024-02-18 14:48:35 -08:00
Brian Smith 9613e5d115 Sync mk/{cargo.sh,install-build-tools.sh} with *ring*.
In particular, LLVM/Clang 18 so that the coverage jobs succeed after
Rust Nightly upgraded to LLVM 18.
2024-02-18 14:46:52 -08:00
Brian Smith 8f81719df5 Appease Clippy. 2024-02-18 13:14:42 -08:00
Brian Smith fe5bbc1ee0 CI: Update versions of cargo-deny and cargo-audit 2023-12-05 18:23:34 -08:00
Brian Smith 8df253ec56 CI: Run tests on more targets. 2023-12-05 18:16:28 -08:00
Brian Smith 1f74481e02 CI: Remove unneeded workaround for no-longer-supported Rust version 2023-12-05 16:57:08 -08:00
Brian Smith 425ee4a7a0 CI: Update use of GitHub Actions Actions to sync with *ring*.
Update action/cache and action/checkout. Remove use of actions-rs.
2023-12-05 16:57:08 -08:00
Brian Smith cace8bb895 CI: Remove now-unneeded aarch64-apple-darwin workaround. 2023-12-05 16:57:08 -08:00
Brian Smith de56edcf40 mk: Sync with *ring*. 2023-12-05 16:25:43 -08:00
Brian Smith f84a538a5c 0.22.4. 2023-10-08 18:27:19 -07:00
Brian Smith f1202b34b3 Restore SemVer compatibility for `verify_is_valid_tls_client_cert`. 2023-10-08 18:27:19 -07:00
Brian Smith 60e688b6c2 0.22.3. 2023-10-08 17:33:58 -07:00
Brian Smith b16d543285 CI: Add aarch64-pc-windows-msvc (build only).
There are no runners in GitHub Actions so we can't run the tests, but at least
we can build them.
2023-10-08 11:03:31 -07:00
Brian Smith e7873ffe4b Restore MSRV to 1.61.0. 2023-10-08 10:31:11 -07:00
Brian Smith ba29bbfce2 Move rcgen-based tests to their own crate.
Remove the `rcgen` dev-dependency from the webpki crate.
2023-10-08 10:31:11 -07:00
Brian Smith 764cc60bfa Tests: Remove redundant `tests` submodule in dos.rs.
The tests submodule was a holdover from when these were unit tests.
2023-10-08 10:31:11 -07:00
Brian Smith bfde8f3b3f Move DoS tests from unit tests to integration tests.
This is an intermediate step towards moving them into a separate crate.

Leave the `tests` submodule for now, to make the comparison with the
old (identical) code easier. The next commit will remove it and
re-indent the code.
2023-10-08 10:31:11 -07:00
Brian Smith 87dd910480 Add `verify_is_valid_tls_server_cert_ext`.
Add a public API that allows the caller to distinguish the new DoS
errors.
2023-10-08 10:31:11 -07:00
Brian Smith cef4925a16 Use *ring* 0.17.2. 2023-10-06 17:43:50 -07:00
Brian Smith 16a2638bd0 Upgrade to *ring* 0.17 and untrusted 0.9.
untrusted 0.9 is used by *ring*. untrusted stopped providing a `PartialEq`
for `Input` in 0.9; this was the driver for all the code changes.
2023-10-02 14:24:17 -07:00
Brian Smith 301128fa01 0.22.2. 2023-10-02 10:28:27 -07:00
Daniel McCarney b5a6f4d9e6 Cargo: unpin rcgen dev-dependency
Rcgen 0.11.3 has been released and fixed the semver breakage that
required temporarily pinning to 0.11.1.
2023-10-02 10:23:59 -07:00
Brian Smith 91992763fb NFC: Correct name of mozilla::pkix in comment. 2023-09-30 11:31:21 -07:00
Brian Smith d96f70b49d NFC: DRY in budget. 2023-09-30 11:31:21 -07:00
Brian Smith 7e0731a016 NFC: Remove `too_many_arguments` exception from clippy.sh. 2023-09-30 11:31:21 -07:00
Brian Smith 2ad08d7bc2 NFC: Clarify `is_fatal()`. 2023-09-30 11:31:21 -07:00
Brian Smith 7793842de1 NFC: Encapsulate `Budget` internals.
Make it clear that nothing is reaching into the internals of `Budget`.
In particular, clarify that the tests are not messing around with the
defaults.
2023-09-30 11:31:21 -07:00
Brian Smith 93aca11db8 Use `"src/**/*.rs"` in Cargo.toml to include sources. 2023-09-30 09:03:22 -07:00
Brian Smith 75e94db494 Remove Cargo.toml.orig. 2023-09-29 22:17:24 -07:00
Tim Düsterhus 911e11c67f Reland Fix typo in Rustdoc for verify_signature().
[`git cherry-pick b481381e914de604df30b1be2fe72d938a5c0e57`.]
2023-09-29 21:50:11 -07:00
Daniel McCarney 52f4db4b85 tests: add BetterTLS path building test suite.
[`git cherry-pick 4a39e2b67d4cddf58b0ea16dd821a04ee2240058`, with support
for Edition 2018 added by Brian.]

This commit introduces the Netflix BetterTLS[0]'s path building test
suite to the webpki integration tests.

This project has a test runner for Rustls that will stand up TLS servers
to exercise these tests but:

* It requires Go.
* It needs Rustls in order to do a full TLS handshake with the test
  servers.
* It's slower than testing the path building directly without the TLS
  bits.

To avoid these issues this commit takes a different approach and vendors
the exported path building test suite. This is a supported feature[1] of
the upstream project and allow us to directly test webpki's path
building against the test suite without needing Rustls or Go.

[0]: https://github.com/Netflix/bettertls
[1]: https://github.com/Netflix/bettertls#exporting-tests-to-run-outside-of-the-bettertls-executor
2023-09-29 21:50:11 -07:00
Daniel McCarney 519bcb6c23 verify_cert: check name constraints after sig. validation
Prior to this commit parsing and processing certificate name constraints
was done before validating a chain of signatures to a known trust
anchor. This increases the attack surface of these features, allowing an
adversary to force webpki to process name constraints on a crafted
certificate without needing to have that certificate issued by a trusted
entity.

This commit moves the parsing and processing of name constraints to
after building and verifying the chain of signatures to reduce the
potential for mischief.
2023-09-29 20:21:44 -07:00
Daniel McCarney 4d0cbba617 signed_data: fix code block missing close marker 2023-09-29 20:21:44 -07:00
Brian Smith 31987f3f09 Pin `rcgen` to 0.11.1 since 0.11.2 broke semver. 2023-09-29 20:21:44 -07:00
Daniel McCarney f566cf1b3b verify_cert: apply path building budget
This is intended to be complementary to the signature validation limit
fix and addresses briansmith/webpki#276 in the same manner as NSS
libmozpkix.
2023-09-29 19:06:31 -07:00
Joseph Birr-Pixton 3ee04be687 Add comment indicating source of signature budget 2023-09-29 19:06:31 -07:00
Joseph Birr-Pixton 636037e9da Track signature limit using `Budget` type 2023-09-29 19:06:31 -07:00
Brian Smith 4a71d475e6 NFC: Address Clippy `explicit_auto_deref`. 2023-08-30 17:04:56 -07:00
Brian Smith 177c39eee5 NFC: Address Clippy `clone_on_copy`. 2023-08-30 17:04:56 -07:00
Brian Smith 3e8d10d72c CI: Clean up Clippy configuration.
None of these lints are triggered.
2023-08-30 17:04:56 -07:00
Brian Smith ae7a99f281 NFC: Address Clippy `useless_asref`. 2023-08-30 17:04:56 -07:00
Brian Smith 6d409c9039 NFC: Address Clippy `redundant_closure`. 2023-08-30 17:04:56 -07:00
Brian Smith ca2472ec5f NFC: Address Clippy `octal_escapes` lint. 2023-08-30 17:04:56 -07:00
Brian Smith d16bafbba4 NFC: Address Clippy `needless_borrow` complaints. 2023-08-30 17:04:56 -07:00
Brian Smith ad1fe9288e Documentation: Stop hard-coding briansmith.org paths.
Let people find the docs on docs.rs.
2023-08-30 17:04:56 -07:00
Brian Smith c81f92e4e8 0.22.1 2023-08-30 14:48:28 -07:00
Daniel McCarney 30a108e080 verify_cert: enforce maximum number of signatures.
Cherry-picked from e473ee1ecb335d8efa3d4ceb2feb369f46b125f2 and modified
by Brian Smith. The main modifications were:

1. Maintain API compatibility with webpki 0.22.0.
2. (In `build_chain_inner`), stop immediately on fatal error, without
   considering any more paths. The point of having such fatal errors
   is to fail ASAP and avoid unneeded work in the failure case.
3. The test uses rcgen which requires Rust 1.67.0 or later. (I don't
   think the non-test MSRV of webpki changes though.)

The original commit message is below:

Pathbuilding complexity can be quadratic, particularly when the set of
intermediates all have subjects matching a trust anchor. In these cases
we need to bound the number of expensive signature validation operations
that are performed to avoid a DoS on CPU usage.

This commit implements a simple maximum signature check limit inspired
by the approach taken in the Golang x509 package. No more than 100
signatures will be evaluated while pathbuilding. This limit works in
practice for Go when processing real world certificate chains and so
should be appropriate for our use case as well.
2023-08-30 14:08:00 -07:00
Daniel McCarney 522cecd950 Cherry pick f0259b9588bab116c7dfbc62524b98794c90aaef: verify: break out build_chain recursion.
[`git cherry-pick f0259b9588bab116c7dfbc62524b98794c90aaef`, merged by Brian Smith.]

Crate-internal consumers of `build_chain` always pass `0` as the sub CA
count, only the `verify_cert.rs` internal recursion changes this
parameter.

This commit separates the external interface from the internal
recursion to remove one extra parameter from an already complicated
interface.
2023-08-30 14:08:00 -07:00
Brian Smith 0cd0b31beb Revert main branch crate contents to the 0.22.0 release contents.
Reset the crate contents (sources, tests, etc.)
to what they were at that commit, while retaining the newer CI
configuration.

The changes since the 0.22.0 release were primarily intended to
accomplish two goals:

* Fix and improve the GitHub Actions configuration.
* Prepare a 0.21.5 release that was backward compatible with 0.21.4
  but which also contained the improvements that were in 0.22.0.

0.21.5 was never released and will not be released. Therefore all
of the noise to facilitate the 0.21.5 release can just be deleted,
as long as we leave the CI changes that are necessary for GitHub
Actions to work correctly now.

The exact commands I used were:

```
git checkout \
    6c334a2cf5 \
    -- \
    Cargo.toml \
    LICENSE \
    README.md \
    src \
    tests \
    third-party
git rm src/trust_anchor_util.rs
```

Commit 6c334a2cf5 was the commit from
which 0.22.0 was released. It is confusing because the commit
immediately prior, 0b7cbf2d32, has
commit message "0.22.0". It appears that I merged the "0.22.0"
commit, expecting to `cargo publish` from that commit, but then
`cargo publish` failed. Then I added
6c334a2cf5 to fix `cargo publish`
and did the `cargo publish` from that commit. That's why I added
the `package` CI step at that time, to prevent this confusing
situation from happening again.

`trust_anchor_utils.rs` was not in 0.22.0; the `git checkout` didn't
delete it, so I had to do it separately.

I left the tests added subsequent to 0.22.0 in `tests/` (e.g.
`name_tests.rs`) since those tests pass with the 0.22.0 sources too.

Unfortunately, this requires disabling a bunch of Clippy lints, to
avoid modifying the contents from 0.22.0.

(I know it is confusing. It took me a while to figure it out myself
today.)
2023-08-30 08:31:51 -07:00