Skip to content

Fix out-of-bounds accesses in debug-only code - #209

Closed
Carmel0 wants to merge 1 commit into
OpenPrinting:masterfrom
Carmel0:fix-debug-only-oob-accesses-v2
Closed

Carmel0 wants to merge 1 commit into
OpenPrinting:masterfrom
Carmel0:fix-debug-only-oob-accesses-v2

Conversation

@Carmel0

@Carmel0 Carmel0 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #196 and #202.

While reviewing similar diagnostic code, I found two remaining out-of-bounds accesses in builds configured with --enable-debug.

In cupsJWTHasValidSignature(), the debug log unconditionally reads the first and last four signature bytes. Importing the compact JWS below, whose decoded signature is one byte, and then calling cupsJWTHasValidSignature() produces a heap-buffer-overflow under AddressSanitizer:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.AA

In the OpenSSL implementation of cupsSignCredentialsRequest(), the debug extension dump writes two hexadecimal characters per DER byte into temp[1024] without limiting the extension length. A certificate request containing 30 subjectAltName values produces a stack-buffer-overflow under AddressSanitizer. The corresponding 32-byte JWS signature and two-name certificate request controls were clean in the same build.

Only emit the detailed first/last signature dump when both four-byte windows fit without overlap, and stop the extension dump before the next formatted byte would exceed the buffer. These paths are compiled out of normal release builds; the changes only bound diagnostic output and do not alter JWT verification or certificate processing.

Assisted-by: OpenAI Codex

@michaelrsweet michaelrsweet self-assigned this Nov 13, 2026
@michaelrsweet michaelrsweet added the enhancement New feature or request label Nov 13, 2026
@michaelrsweet michaelrsweet added this to the Stable milestone Nov 13, 2026
@michaelrsweet

Copy link
Copy Markdown
Member

[master bea4185] Fix debug printfs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants