Skip to content

(release/25.0) xkb: Add bounds check for action data in CheckKeyActions()#2814

Open
metux wants to merge 1 commit into
release/25.0from
pr/release/25.0-xkb-add-bounds-check-for-action-data-in-checkkeyactions-_2026-05-18_20-31-18
Open

(release/25.0) xkb: Add bounds check for action data in CheckKeyActions()#2814
metux wants to merge 1 commit into
release/25.0from
pr/release/25.0-xkb-add-bounds-check-for-action-data-in-checkkeyactions-_2026-05-18_20-31-18

Conversation

@metux
Copy link
Copy Markdown
Contributor

@metux metux commented May 18, 2026

CheckKeyActions() validates the per-key action count bytes individually
but does not verify that the computed total action data region falls
within the request buffer before advancing the wire pointer past it.

After the loop, the function calculates the final wire position as
wire + nActs * sizeof(XkbAnyAction), where nActs is the sum of per-key
action counts read from the request. The upstream length validation in
_XkbSetMapCheckLength() uses req->totalActs from the request header,
not the computed nActs. If a crafted request provides a totalActs value
that passes the length check but per-key action counts that sum to a
different nActs, the wire pointer could advance past the actual request
buffer.

The subsequent SetKeyActions() function uses memcpy to read from this
potentially out-of-bounds region, which could leak heap data or cause
a crash.

Assisted-by: Claude:claude-claude-opus-4-6
Part-of: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2208

CheckKeyActions() validates the per-key action count bytes individually
but does not verify that the computed total action data region falls
within the request buffer before advancing the wire pointer past it.

After the loop, the function calculates the final wire position as
wire + nActs * sizeof(XkbAnyAction), where nActs is the sum of per-key
action counts read from the request. The upstream length validation in
_XkbSetMapCheckLength() uses req->totalActs from the request header,
not the computed nActs. If a crafted request provides a totalActs value
that passes the length check but per-key action counts that sum to a
different nActs, the wire pointer could advance past the actual request
buffer.

The subsequent SetKeyActions() function uses memcpy to read from this
potentially out-of-bounds region, which could leak heap data or cause
a crash.

Assisted-by: Claude:claude-claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2208>
@metux metux self-assigned this May 18, 2026
@metux metux requested a review from a team May 18, 2026 18:31
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.

2 participants