Skip to content

oprf: reject input and info that overflow the length prefix - #694

Open
dxbjavid wants to merge 1 commit into
cloudflare:mainfrom
dxbjavid:oprf-input-length-bound
Open

oprf: reject input and info that overflow the length prefix#694
dxbjavid wants to merge 1 commit into
cloudflare:mainfrom
dxbjavid:oprf-input-length-bound

Conversation

@dxbjavid

@dxbjavid dxbjavid commented Aug 26, 2026

Copy link
Copy Markdown

The OPRF and POPRF hashing steps frame each variable-length field with I2OSP(len, 2) as RFC 9497 specifies, and the prefix is built with a uint16 cast over the field length. For the client input, the server-side full-evaluation input, and the DeriveKey info that length is never bounded first, so a value of 65536 bytes or more wraps the two-byte prefix (a 65536-byte input encodes a length of 0) and the value is accepted rather than rejected. scalarFromInfo already guards its info with the same math.MaxUint16 check and returns ErrInvalidInfo, so the eval-path info is fine, but the sibling sites that frame the input and the derive-key info were missed. I came across it while comparing the length-prefix handling across the package and confirmed all three call sites accept an over-length value today. The change adds the same bound at blind, fullEvaluate, and DeriveKey, and keeps the maximum admissible length of 65535 bytes working so valid callers are unaffected.


Open in Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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