Skip to content

Use cupsGetRand for web interface session IDs - #1696

Open
Elvand-Lie wants to merge 1 commit into
OpenPrinting:masterfrom
Elvand-Lie:sid-cupsgetrand
Open

Use cupsGetRand for web interface session IDs#1696
Elvand-Lie wants to merge 1 commit into
OpenPrinting:masterfrom
Elvand-Lie:sid-cupsgetrand

Conversation

@Elvand-Lie

@Elvand-Lie Elvand-Lie commented Sep 11, 2026

Copy link
Copy Markdown

The web interface session ID is the CSRF token. Right now it comes from a time-seeded PRNG mixed with values the requester already knows, so it's predictable on plenty of Linux setups. CVE-2018-4700 only improved the seed resolution. Project Zero asked for real entropy in 2018 (issue 42450776), never landed.

This takes 16 bytes from cupsGetRand instead. Same 32-hex cookie format. Nothing else changes. Rework of #1695 like you suggested. Same construction is still on 2.4.x.

@Elvand-Lie
Elvand-Lie marked this pull request as draft September 11, 2026 17:26
The web interface session ID is generated from a time-seeded PRNG mixed
with REMOTE_ADDR, SERVER_NAME and SERVER_PORT. On configurations where
CUPS_RAND is random(), the ID is predictable from values the requester
already knows. CVE-2018-4700 improved the seed resolution but kept it
time-derived; Project Zero issue 42450776 asked for real entropy.

Generate the ID from 16 bytes of cupsGetRand, keeping the 32-character
hexadecimal cookie format. Follow-up to OpenPrinting#1695, reworked to use
cupsGetRand as suggested there.
@Elvand-Lie
Elvand-Lie marked this pull request as ready for review September 11, 2026 17:32
@Elvand-Lie
Elvand-Lie marked this pull request as draft September 11, 2026 17:35
@Elvand-Lie
Elvand-Lie marked this pull request as ready for review September 11, 2026 17:45
@michaelrsweet michaelrsweet self-assigned this Sep 11, 2026
@michaelrsweet michaelrsweet added the investigating Investigating the issue label Sep 11, 2026
@michaelrsweet

Copy link
Copy Markdown
Member

The web interface session ID is the CSRF token. Right now it comes from a time-seeded PRNG mixed with values the requester already knows, so it's predictable on plenty of Linux setups. CVE-2018-4700 only improved the seed resolution. Project Zero asked for real entropy in 2018 (issue 42450776), never landed.

Seriously, seeding with microseconds may not be sufficient for crypto, but for a CSRF token of a web interface whose request/response timing is measured in milliseconds it is more than sufficient.

@michaelrsweet michaelrsweet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Generally looks OK, although we'll need to do some cleanup and this change doesn't get top billing in the changelog...

@michaelrsweet michaelrsweet added enhancement New feature or request security Security issue and removed investigating Investigating the issue labels Sep 11, 2026
@michaelrsweet michaelrsweet added this to the v2.5 milestone Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request security Security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants