You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Offhand, it looks like OSSL 3.5 has decided to treat "it says revoked, but the signature is invalid" as "so it's revoked, I guess". But more investigation is required.
Marking as 10.0.0 for completing the investigation to verify the likely change in behavior from OpenSSL, which would result in changing the test's assertion.
I started looking at this. It's not new in OpenSSL 3.5. It happened somewhere between 3.0 and 3.5, we just jumped from 3.0 to 3.5.
I have an automated bisect going against OpenSSL between 3.0 and 3.5 to find the commit that introduced the change so we can understand what the intention was. Will report back.
More interestingly, I cannot reproduce any of the failures if I run any of the theories individually. I suspect something is getting memoized when it shouldn't, or some cache key that was introduced in that commit is not taking something in to account.
More anecdotal information: Changing BuildVariantFactories to only return [RSA] instead of [RSA, ECDsa] fixes it. So that is the source of the non-determinism.
I changed the local algorithm variance to EC-DSA only, and saw the failures on OSSL 3.
Looking at how I corrupt signatures, it's position ^2 in one place, and 5 in two others. 5 bytes in for an EC-DSA signature on secp521r1 is part of the DER structure. OSSL might be getting angry at "the signature isn't even structurally valid".
I'm going to try running a few times with all tampers at ^2, which should always be part of the signature payload. The first run passed.
So, changing to ^2 has made me not see a failure in a half hour of constant runs...
but I'm confused now, as the ECDsa factory uses secp384r1, not secp521r1. 384r1 would be a 48 byte field width, so won't clear the 127 bytes for needing the SEQUENCE length to get bigger.. but [5] would be the first byte of an INTEGER value, so maybe OSSL is getting angry about a bit pattern it ends up with...
There are only two special ones:
0b0000_0000_0xxx_xxxx and 0b1111_1111_1xxx_xxxx. I guess there's a 1/512 chance that it was a 0x00 followed by 0x80+ or 0xFF followed by 0x7F- and got flipped to an invalid integer... but then, man, I got lucky to fail 7 tests when I first forced all the tests to be EC-DSA only.
0b0000_0000_0xxx_xxxx and 0b1111_1111_1xxx_xxxx. I guess there's a 1/512 chance that it was a 0x00 followed by 0x80+ or 0xFF followed by 0x7F- and got flipped to an invalid integer... but then, man, I got lucky to fail 7 tests when I first forced all the tests to be EC-DSA only.
If r in unsigned form is 384 bits in length and has the high bit set (50% chance assuming that r is uniformly distributed), then in unsigned form it would be 0b0000_0000_1xxx_xxxx. Tampering would make that invalid (0b1111_1111_1xxx_xxxx). So I'd expect it to happen over half the time..
The high bit won't have a full 50% chance of being a 1, since the modulus isn't 2^^384, but, yeah, that's a good point... it should have been failing any time that there was a padding byte set to 0.
Oddly enough, every failure I captured was the "now the top 9 bits are 0", which means the signature was encoded as having a negative number...
SIGH.
[5] isn't the 5th byte, it's the 6th. I was looking at the wrong byte in my memory projection.
So, yes, the problem is actually
The r value has bit 383 set, so it needs a 0x00 padding byte.
I then come along and flip the byte after the padding byte, it now goes from 0b1xxx_xxxx to 0b0xxx_xxxx.
And as I've nerd-sniped myself... I believe it's a
49.9999999999999999999999999999999999999999999999999999999999999999999999999991% chance, since p=0XFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF
But, sure, if you don't live your life to what... 78 significant figures, you can call it 50% 😄
Activity
dotnet-policy-service commentedon Jul 2, 2025
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.
bartonjs commentedon Jul 10, 2025
Offhand, it looks like OSSL 3.5 has decided to treat "it says revoked, but the signature is invalid" as "so it's revoked, I guess". But more investigation is required.
jeffhandley commentedon Jul 22, 2025
Marking as 10.0.0 for completing the investigation to verify the likely change in behavior from OpenSSL, which would result in changing the test's assertion.
vcsjones commentedon Jul 31, 2025
I started looking at this. It's not new in OpenSSL 3.5. It happened somewhere between 3.0 and 3.5, we just jumped from 3.0 to 3.5.
I have an automated bisect going against OpenSSL between 3.0 and 3.5 to find the commit that introduced the change so we can understand what the intention was. Will report back.
vcsjones commentedon Aug 3, 2025
Okay. This is an interesting one. I can also reproduce it against OpenSSL 3.0.
A bisect of the runtime shows it started in 00b0050. /cc @bartonjs
On e231b75:
On 00b0050:
More interestingly, I cannot reproduce any of the failures if I run any of the theories individually. I suspect something is getting memoized when it shouldn't, or some cache key that was introduced in that commit is not taking something in to account.
vcsjones commentedon Aug 3, 2025
It also fails non-deterministically. Sometimes it's 1 failure, or 4 failures, or something in-between.
vcsjones commentedon Aug 3, 2025
More anecdotal information: Changing
BuildVariantFactoriesto only return[RSA]instead of[RSA, ECDsa]fixes it. So that is the source of the non-determinism.vcsjones commentedon Aug 3, 2025
In short: the combination of
CorruptRevocationSignatureand ECDsa revocation responders does not seem to work.vcsjones commentedon Aug 4, 2025
Actually I can, that was the non-determinism biting me.
bartonjs commentedon Aug 4, 2025
I changed the local algorithm variance to EC-DSA only, and saw the failures on OSSL 3.
Looking at how I corrupt signatures, it's position ^2 in one place, and 5 in two others. 5 bytes in for an EC-DSA signature on secp521r1 is part of the DER structure. OSSL might be getting angry at "the signature isn't even structurally valid".
I'm going to try running a few times with all tampers at ^2, which should always be part of the signature payload. The first run passed.
bartonjs commentedon Aug 4, 2025
So, changing to ^2 has made me not see a failure in a half hour of constant runs...
but I'm confused now, as the ECDsa factory uses secp384r1, not secp521r1. 384r1 would be a 48 byte field width, so won't clear the 127 bytes for needing the SEQUENCE length to get bigger.. but [5] would be the first byte of an INTEGER value, so maybe OSSL is getting angry about a bit pattern it ends up with...
There are only two special ones:
0b0000_0000_0xxx_xxxx and 0b1111_1111_1xxx_xxxx. I guess there's a 1/512 chance that it was a 0x00 followed by 0x80+ or 0xFF followed by 0x7F- and got flipped to an invalid integer... but then, man, I got lucky to fail 7 tests when I first forced all the tests to be EC-DSA only.
bartonjs commentedon Aug 4, 2025
aaaaaaand... confirmed!
I captured an output from right before a failure (reverting everything to edit at [5]):
It looks like a perfectly valid OCSP Response:
But eagle eyed BER nerds will notice
02:31:00:4c, which violates the rules of BER INTEGER.You (me) should look at how many passed, though. Law of large numbers, my friend.
vcsjones commentedon Aug 4, 2025
Makes sense, but I am not sure why "corrupting it but not corrupting it enough" means "Revoked".
PranavSenthilnathan commentedon Aug 4, 2025
If
rin unsigned form is 384 bits in length and has the high bit set (50% chance assuming thatris uniformly distributed), then in unsigned form it would be0b0000_0000_1xxx_xxxx. Tampering would make that invalid (0b1111_1111_1xxx_xxxx). So I'd expect it to happen over half the time..bartonjs commentedon Aug 4, 2025
The high bit won't have a full 50% chance of being a 1, since the modulus isn't 2^^384, but, yeah, that's a good point... it should have been failing any time that there was a padding byte set to 0.
Oddly enough, every failure I captured was the "now the top 9 bits are 0", which means the signature was encoded as having a negative number...
SIGH.
[5] isn't the 5th byte, it's the 6th. I was looking at the wrong byte in my memory projection.
So, yes, the problem is actually
Which is, as you say, roughly 50% of the time.
bartonjs commentedon Aug 4, 2025
And as I've nerd-sniped myself... I believe it's a
49.9999999999999999999999999999999999999999999999999999999999999999999999999991% chance, since p=0XFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF
But, sure, if you don't live your life to what... 78 significant figures, you can call it 50% 😄