Menu

AST Pattern Disambiguation in Semgrep SAST: Eliminating Duplicate Win32 StrCatA and POSIX strcat Findings
📰

AST Pattern Disambiguation in Semgrep SAST: Eliminating Duplicate Win32 StrCatA and POSIX strcat Findings

DEV Community: cpp·Aryan Rajput·about 3 hours ago
#1LLQp8Wz
#devtocpp#devto#dev#strcat#strcata
Reading 0:00
15s threshold

The Hook

Nothing erodes developer trust in a SAST pipeline faster than a single line of C code triggering two separate buffer-overflow rules simultaneously—one for POSIX strcat and a second false match claiming the code called Microsoft's Win32 StrCat API.

The Deep Dive

GitLab's static analysis engine relies on curated Semgrep rule packs maintained in gitlab-org/security-products/sast-rules to detect memory-safety flaws (such as CWE-120 buffer copies without checking size of input) across C and C++ codebases. To provide accurate remediation guidance across operating systems, the rule repository separates standard C library string concatenation ( c/buffer/rule-strcat.yml , targeting lowercase strcat(...) ) from Windows Shell/ATL string manipulation APIs ( c/buffer/rule-StrCat-StrCatA.yml , targeting StrCat , StrCatA , and StrCatW ).

While auditing duplicate C buffer findings and authoring MR !747 ( fix: correct StrCat rule case sensitivity ) in sast-rules , I examined why standard POSIX C files calling…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.