fix: verify_server_keys_response fails on non-standard json fields #2415

Merged
ginger merged 2 commits from hexchen/continuwuity:push-wkvumosuykpx into main 2026-11-18 15:10:52 +00:00
Contributor

Previously verify_server_keys_response would work with re-serialized
ServerSigningKeys, which drops any extra, non-standard fields from the
origin server response. The signature is made over the whole response
though, meaning that any response including extra fields will not pass
signature verification.

Fixes: #2407

Pull request checklist:

  • This pull request targets the main branch, and the branch is named something other than
    main.
  • I have written an appropriate pull request title and my description is clear.
  • I understand I am responsible for the contents of this pull request.
  • I have followed the contributing guidelines:
Previously `verify_server_keys_response` would work with re-serialized ServerSigningKeys, which drops any extra, non-standard fields from the origin server response. The signature is made over the whole response though, meaning that any response including extra fields will not pass signature verification. Fixes: #2407 **Pull request checklist:** - [x] This pull request targets the `main` branch, and the branch is named something other than `main`. - [x] I have written an appropriate pull request title and my description is clear. - [x] I understand I am responsible for the contents of this pull request. - I have followed the [contributing guidelines][c1]: - [x] My contribution follows the [code style][c2], if applicable. - [x] I ran [pre-commit checks][c1pc] before opening/drafting this pull request. - [x] I have [tested my contribution][c1t] (or proof-read it for documentation-only changes) myself, if applicable. This includes ensuring code compiles. - [x] My commit messages follow the [commit message format][c1cm] and are descriptive. [c1]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md [c2]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/docs/development/code_style.mdx [c1pc]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#pre-commit-checks [c1t]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#running-tests-locally [c1cm]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#commit-messages
fix: verify_server_keys_response fails on non-standard json fields
Some checks failed
Auto Labeler / Apply labels based on changed files (pull_request_target) Successful in 3s
Checks / Changelog / Check changelog is added (pull_request_target) Failing after 7s
Documentation / Build and Deploy Documentation (pull_request) Has been cancelled
Checks / Prek / Pre-commit & Formatting (pull_request) Has been cancelled
Checks / Prek / Check changed files (pull_request) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
1e4221389c
Previously `verify_server_keys_response` would work with re-serialized 
ServerSigningKeys, which drops any extra, non-standard fields from the
origin server response. The signature is made over the whole response
though, meaning that any response including extra fields will not pass
signature verification.
hexchen force-pushed push-wkvumosuykpx from 1e4221389c
Some checks failed
Auto Labeler / Apply labels based on changed files (pull_request_target) Successful in 3s
Checks / Changelog / Check changelog is added (pull_request_target) Failing after 7s
Documentation / Build and Deploy Documentation (pull_request) Has been cancelled
Checks / Prek / Pre-commit & Formatting (pull_request) Has been cancelled
Checks / Prek / Check changed files (pull_request) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
to 9770374131
Some checks failed
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 7s
Documentation / Build and Deploy Documentation (pull_request) Has been cancelled
Checks / Prek / Pre-commit & Formatting (pull_request) Has been cancelled
Checks / Prek / Check changed files (pull_request) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
2026-10-26 16:04:09 +00:00
Compare
hexchen force-pushed push-wkvumosuykpx from 9770374131
Some checks failed
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 7s
Documentation / Build and Deploy Documentation (pull_request) Has been cancelled
Checks / Prek / Pre-commit & Formatting (pull_request) Has been cancelled
Checks / Prek / Check changed files (pull_request) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
to c52456063a
All checks were successful
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 7s
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Check changed files (pull_request) Successful in 7s
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 1m22s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 9m25s
2026-10-26 16:04:48 +00:00
Compare
nex requested review from nex 2026-10-30 01:24:30 +00:00
Owner

This is generally fine but I don't like how we still pass around both versions of the value, and also ultimately end up storing the deserialised value that may have been stripped of unknown keys. I'll push the changes I want to your branch, then i think it'll be fine to merge

This is generally fine but I don't like how we still pass around both versions of the value, and also ultimately end up storing the deserialised value that may have been stripped of unknown keys. I'll push the changes I want to your branch, then i think it'll be fine to merge
nex self-assigned this 2026-11-02 05:34:56 +00:00
nex force-pushed push-wkvumosuykpx from c52456063a
All checks were successful
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 7s
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Check changed files (pull_request) Successful in 7s
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 1m22s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 9m25s
to 42b203acce
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 1m14s
Checks / Prek / Check changed files (pull_request) Successful in 6s
Update flake hashes / update-flake-hashes (pull_request) Successful in 1m25s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 9m4s
Checks / Changelog / Check changelog is added (pull_request_target) Has been cancelled
2026-11-11 07:52:24 +00:00
Compare
fix: Wrap parsed & raw values
Some checks failed
Checks / Changelog / Check changelog is added (pull_request_target) Has been cancelled
Documentation / Build and Deploy Documentation (pull_request) Has been cancelled
Checks / Prek / Pre-commit & Formatting (pull_request) Has been cancelled
Checks / Prek / Check changed files (pull_request) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
d6840a865a
Rather than passing them around separately everywhere, just unify them into a single struct that is primarily fetched via a raw.
Also stores raw data directly into the database so that signatures can be verified later rather than only at receive time.
Owner

Ended up carrying around the raw and deserialised value everywhere anyway, but this seems like a non-evil middleground solution that achieves the original goal of ensuring the original raw content isn't lost between receive time and storage time (and beyond)

Ended up carrying around the raw and deserialised value everywhere anyway, but this seems like a non-evil middleground solution that achieves the original goal of ensuring the original raw content isn't lost between receive time and storage time (and beyond)
nex requested review from Owners 2026-11-11 08:26:23 +00:00
nex added this to the 26.11.0 milestone 2026-11-11 08:26:26 +00:00
@ -0,0 +1 @@
Fix remote server key signature verification when extra fields exist. Contributed by @hexchen
Contributor

bugfix

bugfix
hexchen marked this conversation as resolved
@ -38,3 +38,4 @@
continue;
}
let trusted = services.config.trusted_servers.iter().any(|notary| {
// Re-verifying here rejects any key that passes extra,
Contributor

stale comment no ?

stale comment no ?
hexchen marked this conversation as resolved
@ -58,2 +83,4 @@
/// `notary` must either be empty or have ONE entry. Extraneous notaries
/// will be ignored.
///
/// `raw_server_keys` must be the response exactly as received. Signatures
Contributor

stale comment ?

stale comment ?
hexchen marked this conversation as resolved
hexchen force-pushed push-wkvumosuykpx from d6840a865a
Some checks failed
Checks / Changelog / Check changelog is added (pull_request_target) Has been cancelled
Documentation / Build and Deploy Documentation (pull_request) Has been cancelled
Checks / Prek / Pre-commit & Formatting (pull_request) Has been cancelled
Checks / Prek / Check changed files (pull_request) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
to a2cfac976d
Some checks failed
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 7s
Documentation / Build and Deploy Documentation (pull_request) Has been cancelled
Checks / Prek / Pre-commit & Formatting (pull_request) Has been cancelled
Checks / Prek / Check changed files (pull_request) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
2026-11-11 08:45:07 +00:00
Compare
hexchen force-pushed push-wkvumosuykpx from a2cfac976d
Some checks failed
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 7s
Documentation / Build and Deploy Documentation (pull_request) Has been cancelled
Checks / Prek / Pre-commit & Formatting (pull_request) Has been cancelled
Checks / Prek / Check changed files (pull_request) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
to 09dd134310
All checks were successful
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 6s
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Check changed files (pull_request) Successful in 9s
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 2m57s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 15m32s
2026-11-11 13:17:13 +00:00
Compare
ginger approved these changes 2026-11-18 15:02:53 +00:00
ginger left a comment

this kind of sucks but if it works I can't complain that much

this kind of sucks but if it works I can't complain that much
ginger merged commit 8ffa3e5367 into main 2026-11-18 15:10:52 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
continuwuation/continuwuity!2415
No description provided.