Skip to content

bugfix: authenticate session tokens and randomize CBC IVs. - #46

Merged
zhuizhuhaomeng merged 1 commit into
masterfrom
dev
Oct 25, 2026
Merged

zhuizhuhaomeng merged 1 commit into
masterfrom
dev

Conversation

@zhuizhuhaomeng

Copy link
Copy Markdown
Contributor

Replace the public MD5 prefix and fixed CBC IV with a versioned token containing a random IV and an HMAC-SHA256 tag. Derive the MAC key separately and authenticate the header and ciphertext before decryption.

Add independent token vectors, tamper and expiry checks, binary boundary coverage, and random-source failure injection. Load the fault injector before Test::Nginx initializes so it also works under Valgrind.

Validation: all 86 Test::Nginx assertions pass on nginx 1.31.8 with OpenSSL 3.5.8. The random-source failure test also passes under Valgrind.

BREAKING CHANGE: Legacy session tokens are rejected. The configured IV is ignored; all nodes exchanging tokens must upgrade together, and existing sessions must be reissued.

Replace the public MD5 prefix and fixed CBC IV with a versioned token
containing a random IV and an HMAC-SHA256 tag. Authenticate the header
and ciphertext before decryption.

Derive the MAC key once per configured encryption key and share cached
key material with inheriting configurations. Cleanse keys when the
configuration pool is released, and rebuild them on reload.

Add independent token vectors, tamper and expiry checks, binary boundary
coverage, key isolation and inheritance checks, and random-source failure
injection. Load the fault injector before Test::Nginx initializes so it
also works under Valgrind.

Validation: all 89 Test::Nginx assertions pass normally and under
Valgrind on nginx 1.31.8 with OpenSSL 3.5.7. Additional probes confirm key
derivation is absent from the request path and key rotation works after
reload.

BREAKING CHANGE: Legacy session tokens are rejected. The configured IV is
ignored; all nodes exchanging tokens must upgrade together, and existing
sessions must be reissued.
@zhuizhuhaomeng
zhuizhuhaomeng merged commit bb3412b into master Oct 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant