Skip to content

net/srtp: teardown salt hygiene and fail-closed cipher checks - #445

Merged
haaspors merged 2 commits into
masterfrom
srtp-crypto-hardening
Aug 3, 2026
Merged

net/srtp: teardown salt hygiene and fail-closed cipher checks#445
haaspors merged 2 commits into
masterfrom
srtp-crypto-hardening

Conversation

@haaspors

@haaspors haaspors commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Two small SRTP hardening fixes surfaced by the security audit of the RFC 6904 header-extension work (#444). Independent of each other; one commit each.

Clear the session salt on teardown

The per-session salt is derived from the master key, but r_srtp_state_clear freed the stream state without zeroing it. Clear it at teardown so it is not left in freed heap, matching how the key-derivation scratch is already wiped.

Fail closed if the payload cipher rejects the request

The RTP and RTCP encrypt/decrypt paths ignored the return value of r_crypto_cipher_encrypt / r_crypto_cipher_decrypt. A cipher that cannot service the call — for example an AEAD cipher reaching this stream-cipher path — returns without touching the buffer, which would emit or accept an unprotected payload. All four call sites now treat a non-OK result as R_SRTP_ERROR_INTERNAL and produce no output, matching how the other internal errors on these paths are handled.

No current cipher suite triggers this (the defined suites are all counter-mode and return OK), so the guards are latent by design and cannot be exercised by a unit test without a synthetic failing cipher; the existing tests confirm they do not disturb the working path.

Testing

Full suite green on the linux and ASan tiers; both tiers compile warning-free.

haaspors and others added 2 commits August 3, 2026 13:42
The per-session salt is derived from the master key; zero it when a
stream state is torn down rather than leaving it in freed heap, matching
how the key-derivation scratch is already cleared.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The RTP and RTCP encrypt/decrypt paths ignored the return of
r_crypto_cipher_encrypt / _decrypt. A cipher that cannot service the
call — for instance an AEAD cipher reaching this stream-cipher path —
returns without touching the buffer, which would emit or accept an
unprotected payload. Treat a non-OK result as R_SRTP_ERROR_INTERNAL so
the transform produces no output instead, matching how the other
internal errors on these paths are handled.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@haaspors
haaspors merged commit c647e11 into master Aug 3, 2026
18 checks passed
@haaspors
haaspors deleted the srtp-crypto-hardening branch August 3, 2026 11:47
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