Skip to content

Comments

fix(ct_analyzer): escape XML special chars in _compile_csharp()#106

Open
NucleiAv wants to merge 2 commits intotrailofbits:mainfrom
NucleiAv:fix/xml-injection-csharp-analyzer
Open

fix(ct_analyzer): escape XML special chars in _compile_csharp()#106
NucleiAv wants to merge 2 commits intotrailofbits:mainfrom
NucleiAv:fix/xml-injection-csharp-analyzer

Conversation

@NucleiAv
Copy link

source_path and output_dir were embedded into the .csproj f-string without escaping. On Linux, filenames may contain XML-special chars (", <, >, &), allowing a crafted filename to inject arbitrary MSBuild XML (CWE-91 -> CWE-78).

Fix: wrap both values with xml.sax.saxutils.escape() before interpolation. The extra {chr(34): '"'} arg covers double-quotes inside the attribute value (chr(34) avoids an f-string quote conflict on Python < 3.12).

source_path and output_dir were embedded into the .csproj f-string
without escaping. On Linux, filenames may contain XML-special chars
(", <, >, &), allowing a crafted filename to inject arbitrary MSBuild
XML (CWE-91 -> CWE-78).

Fix: wrap both values with xml.sax.saxutils.escape() before
interpolation. The extra {chr(34): '&quot;'} arg covers double-quotes
inside the attribute value (chr(34) avoids an f-string quote conflict
on Python < 3.12).
@tob-scott-a
Copy link
Contributor

tob-scott-a commented Feb 25, 2026

https://github.com/trailofbits/skills/actions/runs/22356340569/job/64847828554?pr=106#step:4:138

Screenshot 2026-02-25 at 9 46 42 AM image

(I suspect there's a whitespace difference here.) Oh, different quote characters.

@NucleiAv
Copy link
Author

NucleiAv commented Feb 25, 2026

issue: there's a diff in the quote sign

@NucleiAv
Copy link
Author

i was changing it... but i see you have already done that... thanks!

@tob-scott-a
Copy link
Contributor

Understood. I'm not quite sure why the other 4 required checks are stuck in "pending" state.

@NucleiAv
Copy link
Author

Those 4 checks look like they need a maintainer to approve/trigger the workflow run from a fork... I don't think there's anything on my end causing it.

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