JWS verify accepts a payload segment with non-zero unused base64url bits
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- Half a day
- Newbie friendliness
- 66/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- cryptography, security
Research direction
Start from jws.JWS.deserialize and jws.JWS.verify, following how the signing input is assembled for the HMAC check; the issue suspects it is rebuilt from the decoded payload rather than the received segment. Reproduce with the provided script against Wycheproof tcId 374, then add a regression test and run the JWS test suite. Done means the AB payload token is rejected while valid tokens still verify.
Written by the indexing model from the issue text.
Description
Low/informational finding, no forgery involved.
jwcrypto 1.6.1 verifies a compact JWS whose payload segment was changed only in its unused base64url bits. In Wycheproof json_web_signature_test.json tcId 374 the payload segment is AB, but the HMAC was computed over AA (both decode to 0x00). RFC 7515 §5.2 step 8 validates the signature against the received signing input, BASE64URL(header) || '.' || BASE64URL(payload), so this one should fail. It looks like the signing input gets rebuilt from the decoded payload instead of using the segment as received.
Impact is just malleability: a second spelling of the same token verifies, and the payload itself doesn't change.
from importlib.metadata import version
from jwcrypto import jwk, jws
# Wycheproof testvectors_v1/json_web_signature_test.json, tcId 374 (expected invalid).
compact = "eyJraWQiOiJoczI1Ni1rZXkiLCJhbGciOiJIUzI1NiJ9.AB.8sL_ycV8G_D-K_2A3I0EW3NoPMeQzv13cAzuHlQ5TAE"
key = jwk.JWK.from_json('{"kty":"oct","kid":"hs256-key","use":"sig","alg":"HS256","k":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}')
obj = jws.JWS()
obj.deserialize(compact)
print("jwcrypto=" + version("jwcrypto"))
try:
obj.verify(key)
except Exception as exc:
print("actual=reject " + type(exc).__name__)
else:
print("actual=accept payload_hex=" + obj.payload.hex())
jwcrypto=1.6.1
actual=accept payload_hex=00
Found while running the Wycheproof JOSE vectors against a set of JWT libraries
- Dominant language
- Python
- Stars
- 478
- Forks
- 132
- Avg merge
- 7h 38m
- Merged PRs (30d)
- 4
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from latchset/jwcrypto
-
Difficulty 3/5 1-2 days Newbie friendliness 70/100
-
Teak and implement HPKE once the RFC is publishedPossibly taken @rjeffman claimed this 96 days ago. Open
Difficulty 5/5 Over a week Newbie friendliness 10/100
-
Shouldn't `jwk.import_from_pyca` also provide a `kid` param and set it to `thumbprint()` by default?OpenEasy Fix enhancement help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
-
enhancement
Difficulty 4/5 Over a week Newbie friendliness 24/100
All issues in latchset/jwcrypto
Similar issues
-
cognition facet:consolidation memory ready size:S
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
proposal
Difficulty 1/5 Under an hour Newbie friendliness 68/100
j3ko/agent-plugins#29 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
-
area:cli area:security bug priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Judgment-Pack/judgment-pack-spec#335 ·
Maintainers usually reply within 1 day