Repository navigation
Conversation
8776ddd to
4b7a5bd
Compare
f2f6fe4 to
1285301
Compare
|
@p-rogalski Can you take a look whether |
|
The multi-timestamp implementation looks good. One pre-existing issue in I suggest checking the digest length first: if (hash_len != EVP_MD_size(md) ||
memcmp(mdbuf, hash_data, (size_t)hash_len)) { |
Preserve existing timestamps when adding new ones and verify every value of both Authenticode and RFC 3161 timestamp attributes. Accept a signature when at least one trusted timestamp and the Authenticode signature both validate at that timestamp's time. Malformed or untrusted alternatives must not hide a valid pair or be treated as absent timestamps. Add -timestamp-all to require every requested TSA, allowing both remote protocols together without changing the existing URL fallback behavior. Reject -timestamp-all without any -t or -ts URL, so it never succeeds without adding a timestamp. Reject excess URLs before writing past the timestamp server arrays and use a while loop for variable-length argument consumption. Document the new verification policy and the change from implicit timestamp replacement to appending.
verify_timestamp_token() compared the computed digest with the token's messageImprint using the imprint's own length. An empty imprint therefore matched any signature, and a short one bound only a prefix of the digest. A trusted TSA that signs such a request, even once, produces a token that can be attached to other signatures to claim an earlier signing time, for example to make a signature with an expired certificate verify. An imprint longer than the digest read past the computed value. Require the imprint length to equal the digest size before comparing. Also reject an unknown imprint algorithm explicitly and check the digest computation, whose failure was previously ignored. Authenticode timestamps are unaffected: CMS_verify() binds them through the messageDigest attribute.
e39c0f9 to
cfb3de2
Compare
|
Closing this in favour of #532, which carries the message imprint length check, the timestamp/time pairing fix and the The multiple-timestamp feature needs a different design. What Windows accepts and uses is recorded in #533: one attribute with two values is rejected outright, and with the values in separate attributes only the first is used, ordered by DER encoding. A second timestamp therefore adds no redundancy there, so |
Pull Request Type
Related Issue
Follow-up to #510: support multiple timestamps on a single signature, rather than retaining just one timestamp for verification.
Current Behavior
Adding a timestamp replaces existing timestamps. Repeated timestamp URLs are fallback servers, and verification reads only the first value of each timestamp attribute, retaining one timestamp for the final check.
New Behavior
addpreserves existing timestamps and appends new ones, including timestamps of the other protocol.-timestamp-allrequires a timestamp from every specified-tand-tsURL and permits both protocols in one invocation. Any failed request fails the operation without leaving a partial output. At least one-tor-tsURL is required, so it never succeeds without adding a timestamp.-timestamp-all, repeated URLs retain their existing fallback behavior: stop after the first successful response.-ignore-timestampretains verification at the requested/current time. Files with multiple signatures still succeed when any eligible signature validates.Example:
Scope of Changes
-timestamp-allto an already timestamped PE file, then verifies the result.messageImprintusing its own length, so a TSA-signed token with an empty or truncated imprint matched any signature. Require the imprint length to equal the digest size (reported by @olszomal).Testing
Linux, GCC 16.2.0, OpenSSL 3.6.4:
ctest6356da1: full serialctestwith ASan+UBSan (-fno-sanitize-recover=undefined), OpenSSL 3.6.5-timestamp-allwithout-t/-tsgit diff --checkStrict UBSan across all formats additionally finds a pre-existing signed-shift error in
appx.c:2822(left shift of 255 by 24 places cannot be represented in type 'int'). Reproduced on basebf7533dusingsigned_256appx; fixed on master by6356da1, which this PR is now rebased onto.Additional Notes
addno longer implicitly replaces existing timestamps. Explicitly remove the signature and sign again to replace them.addinvocations append normally.License Declaration