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 lowercase strcat(dest, src) were emitting duplicate vulnerability reports under both c_buffer_rule-strcat and c_buffer_rule-StrCat-StrCatA. Inspecting the rule definition and test fixtures revealed that c_buffer_rule-StrCat-StrCatA was matching lowercase strcat invocations instead of restricting its AST call-expression pattern strictly to the PascalCase Win32 identifiers StrCat and StrCatA.
In MR !747, I corrected the pattern case sensitivity in c/buffer/rule-StrCat-StrCatA.yml and updated its accompanying C test harness (c/buffer/rule-StrCat-StrCatA.c) so that lowercase strcat(...) is exclusively flagged by c_buffer_rule-strcat, while StrCat(...) and StrCatA(...) are isolated to c_buffer_rule-StrCat-StrCatA. That disambiguation ensures 1-to-1 finding-to-CWE deduplication in CI security artifacts.
The GitLab Hero Angle
By continuously refining AST pattern precision in gitlab-org/security-products/sast-rules (MR !747), GitLab's built-in SAST analyzers deliver high-signal, zero-duplication vulnerability detection across both POSIX C/C++ microservices and legacy Win32 native binaries.
The Takeaway
In multi-platform SAST rule repositories, enforce strict case-sensitive identifier boundaries between POSIX standard library functions (strcat) and PascalCase Win32 macros (StrCat/StrCatA) so a single call site never emits colliding vulnerability fingerprints.
Top comments (0)