Skip to content

XCCDF_POLICY: bound recursion on cyclic Profile @extends#2364

Open
edznux-dd wants to merge 1 commit into
OpenSCAP:mainfrom
edznux-dd:fix/dos-unbounded-recursion
Open

XCCDF_POLICY: bound recursion on cyclic Profile @extends#2364
edznux-dd wants to merge 1 commit into
OpenSCAP:mainfrom
edznux-dd:fix/dos-unbounded-recursion

Conversation

@edznux-dd
Copy link
Copy Markdown

(see #2361 for more context)

This is the 4th and last fix-PR of the series (the next one will be the fuzz harnesses)
This one feels more like hardening but it fixes a stack overflow issue on cyclic/deeply nested @extends chain.

I've set XCCDF_POLICY_MAX_EXTENDS_DEPTH to 64, as an arbitrary value that seems conservative but can be changed if you have stronger opinion. (similar to #2363)

A cyclic Profile @extends chain (A extends B extends A) recursed until the
stack overflowed, both directly and indirectly via policy creation
(_xccdf_policy_add_profile_selectors -> xccdf_policy_model_get_policy_by_id
-> xccdf_policy_new -> back here). Track nesting in a file-static counter and
abort past a sane depth. Also use NULL-safe comparison for the shadowing check.

Note: a sibling unbounded-recursion fix for cyclic ARF catalog component-refs
lives in src/DS/sds.c, which is on the memory-corruption branch because it is
coupled with the use-after-free fix in the same function.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 3, 2026

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