How Cal.com Rebuilt AppSec After Going Closed Source
How Cal.com consolidated noisy security tooling into one continuous, context-aware pull request security program with Gecko.
Gecko Security

C SAST tools have a structural ceiling that shows up in macro-heavy codebases. The preprocessor runs first, rewrites the source, and hands a rewritten artifact to the parser. Any taint flow, bounds check, or type cast that lives inside a macro boundary is invisible in the resulting tree. Getting past that ceiling requires a different approach to analysis entirely, one that starts from what the compiler actually sees.
TLDR:
#ifdef configurations, so engineers get the context they need to act without manually reconstructing what the preprocessor did.C and C++ sit at the intersection of two competing realities: they give developers direct memory access and near-zero runtime overhead, and they give security tools almost nothing to work with at parse time.
The preprocessor runs before any AST gets built. By the time a parser sees the code, macros have already rewritten it, conditional compilation blocks have collapsed, and the original source structure is gone. A tool trying to build an accurate syntax tree is reading a preprocessed artifact, not the code a developer actually wrote. Static code analysis depends on a stable representation that the C preprocessor actively destroys.
Macros in C and C++ are text substitutions, not syntax constructs. A single macro invocation can expand into dozens of tokens, span expression boundaries, or generate entirely different code depending on which headers were included first.
#ifdef can produce code paths that contradict each other depending on build flags, and a parser that picks one variant silently drops the others.Most AST-based C SAST tools attempt to parse a single translation unit in isolation. That approach has a hard ceiling. Type information for function parameters defined in one file is unavailable when analyzing calls in another, which breaks inter-procedural reasoning. Build-system complexity means the set of active #define values is rarely recoverable without actually invoking the compiler.
The result is that cpp security analysis built on ASTs produces findings that are structurally disconnected from the real execution environment: wrong types, phantom branches, and call graphs with missing edges.
The parse-then-analyze pipeline starts with source text. A lexer tokenizes it, a parser builds an AST from those tokens, a tree where nodes represent syntactic constructs: function declarations, expressions, variable references, control flow statements. Analysis rules then traverse specific node types looking for patterns.
Looking for a call to strcpy? Walk the tree for function call nodes matching that identifier. Missing null check before a pointer dereference? Find dereference nodes whose operand has no preceding conditional guard. Intra-function taint tracking, where user input reaches printf without sanitization, follows data-flow edges between nodes within the same translation unit.
These syntactic patterns are where AST-based C SAST genuinely delivers. Understanding SAST vs DAST clarifies why static approaches have hard structural limits that runtime testing can sometimes compensate for. Decades of accumulated rules cover dangerous standard library functions, integer overflow patterns, and format string misuse with real accuracy.
strcpy, gets, and sprintf are reliably caught because they appear as named call nodes in the AST regardless of surrounding context.The C preprocessor runs before any parser sees a single token. By the time an AST tool gets to work, macros have already fired, conditional compilation blocks have been included or excluded, and the source text that actually compiled looks nothing like what the developer wrote.
Consider a pattern common in embedded and systems code:
#define SAFE_WRITE(dst, src, len) \
memcpy((dst), (src), (len))An AST parser sees the memcpy call after expansion. It has no record that a macro wrapped it, no knowledge of what arguments the call site originally passed, and no way to trace taint back through the macro boundary. The macro is invisible. The vulnerability surface it creates is invisible too.
Macros alone are hard enough. Conditional compilation compounds the problem because a C SAST tool analyzing one translation unit sees only the branch that was active for that build configuration. Every #ifdef, #ifndef, and #if defined(...) block is a branching point where the actual code depends on compile-time flags the static analyzer may not have.
A security researcher doing C++ static analysis of a codebase with platform-specific or feature-flag-gated paths cannot trust that the AST they are inspecting reflects all reachable code. This same structural gap explains why static analysis misses business logic flaws more broadly. Entire vulnerability classes can hide behind the wrong build flag.
The only approaches that fully handle this require either running the preprocessor as part of the analysis pipeline and reasoning over the post-expansion code with full context, or modeling all reachable macro expansions across the build matrix.
Macros in C and C++ operate as a text substitution layer that runs before the compiler ever sees the code. By the time an AST parser gets involved, the preprocessor has already rewritten the source, and that rewritten form is what gets parsed. The result is that the AST reflects post-expansion code, but most analysis tools map findings back to the original source incorrectly, or lose context entirely.
Several patterns cause the most consistent failures:
##) combine identifiers at the preprocessing stage, producing symbol names that never existed in the original source. An AST parser has no mechanism to trace these back to their macro origin, which breaks cross-reference resolution and leaves call graphs with dangling or unresolvable nodes.#ifdef, #if defined) mean that a single file can produce radically different ASTs depending on which flags are active at parse time. C SAST tools that parse without a full build configuration miss entire code paths, producing incomplete analysis coverage.do { ... } while(0) constructs can confuse scope and control-flow analysis. The AST sees a loop where no loop was intended, and control flow edges get misattributed.The root problem is that AST-based cpp security tools are structurally dependent on a stable, predictable syntax tree. Macros remove that stability before the tree is ever built.
When macros obscure code structure, the consequences go beyond parse failures. They create blind spots where real vulnerabilities live undetected through entire release cycles.
Three vulnerability classes appear repeatedly in macro-heavy C and C++ codebases that static analyzers fail to catch:
These gaps are structural. No amount of rule-tuning recovers a vulnerability that was never represented in the analysis graph to begin with. Teams that need coverage beyond static analysis often pair SAST with automated pentest tools and best practices to exercise paths no parser ever sees. The only path forward is preprocessing before analysis, or building analysis directly on the preprocessed representation so every macro expansion is visible as real code.
Macros are only the beginning. In C and C++ projects, the build system itself determines which code actually compiles, and most AST parsers have no access to that information.
Consider a codebase that targets Linux, Windows, and embedded hardware. Each target activates different #ifdef branches, links different libraries, and may define entirely different security-sensitive paths. A parser that reads source files without a compilation database sees all of those branches simultaneously, or worse, picks one arbitrarily. Neither outcome reflects what ships.
Tools like clang-based parsers can ingest a compile_commands.json file to get accurate flags per translation unit, and the Clang JSON Compilation Database spec defines exactly what that file must contain. That closes part of the gap, though for surface exposure, API scanning and automated security testing catches runtime issues the compiler never surfaces:
__GNUC__ and toolchain-specific guards expand as they would during an actual build.But generating that compilation database requires a working build environment, which is often unavailable in CI pipelines, cross-compilation setups, or legacy projects where the build system predates CMake. C SAST tools that depend on it fail silently on the codebases where C++ static analysis matters most. Assessing the best AI security tools by how they handle compilation databases is a useful filter for separating genuine semantic analysis from surface-level pattern matching.
Getting past the macro ceiling requires moving away from AST-based parsing entirely.
Three approaches have meaningfully improved C and C++ static analysis accuracy where macro-heavy codebases are concerned.
Tools that plug directly into the compiler front end (Clang's LibTooling, for example) receive the fully preprocessed, macro-expanded translation unit. The analysis sees what the compiler sees: concrete token sequences, resolved type information, and accurate source locations. False negatives from unexpanded macros drop sharply because there are no unexpanded macros left by the time analysis begins. The tradeoff is build-system coupling, but for C SAST use cases where accuracy matters more than portability, this is the practical starting point.
Code property graphs encode control flow, data flow, and call relationships in a single queryable structure. Where an AST loses context at macro boundaries, a semantic graph preserves the relationships that matter for vulnerability reasoning. Cross-function taint paths through macro-defined dispatch tables stay intact instead of disappearing into unresolvable nodes. Several AI-powered application security testing tools have adopted semantic graph representations as a result.
Gecko's approach to C and C++ security analysis reasons over a compiler-accurate semantic model instead of surface-level AST patterns. Macro expansions are resolved before analysis begins, so taint flows that cross macro-defined boundaries remain visible. The result is that findings carry working proof-of-concept exploits, going beyond pattern matches against token streams that may or may not reflect runtime behavior.
Consider a pattern common in systems code where the taint sink lives behind a macro boundary:
#define COPY_INPUT(dst, src, len) memcpy((dst), (src), (len))
void handle_request(const char *user_data, size_t user_len) {
char buf[256];
COPY_INPUT(buf, user_data, user_len); // taint: user_data flows to memcpy dst
}An AST-based tool sees the COPY_INPUT call site; the memcpy and the missing bounds check exist only after expansion. Gecko resolves the macro before analysis runs, so the taint path from user_data through the expansion to the memcpy destination is fully visible, and the missing length validation against sizeof(buf) surfaces as a finding with a working proof-of-concept.
When assessing C SAST tools for codebases that rely heavily on macros, a few properties separate tools that actually work from ones that produce noise.
Look for tools that expand macros before analysis, not after. The analyzer needs to see the code as the compiler sees it, with all substitutions resolved, so taint flows and control paths remain intact across macro boundaries.
Single-file analysis breaks down the moment a macro defined in one header affects logic in another translation unit. Inter-procedural analysis across the full compilation scope is a hard requirement here, not an optional feature.
Macro-generated code inflates false positive rates. Tools should let teams annotate or exclude known-safe macro expansions without suppressing entire rule categories.
Pattern-matching engines fail on macro output because the surface syntax no longer resembles what the developer wrote, a problem that compounds when securing AI-generated code, which frequently relies on macro-heavy boilerplate. An analyzer that reasons over the semantic graph of expanded code handles this without special-case rules.
| Property | Why It Matters for Macros |
|---|---|
| Pre-analysis macro expansion | Preserves taint paths through substituted code |
| Inter-procedural scope | Catches flows that cross header/translation-unit boundaries |
| Expansion-aware suppression | Reduces noise without losing real findings |
| Semantic graph analysis | Handles non-standard syntax macro output produces |
Gecko's approach to C and C++ SAST starts where conventional tools stop: at the macro boundary.
Instead of expanding macros before parsing or ignoring them entirely, Gecko builds a compiler-accurate semantic graph that preserves macro invocation sites, their expansion context, and the resulting token sequences as first-class nodes. A macro that rewrites a bounds check or conditionally includes a pointer dereference remains visible and queryable in the graph, instead of silently collapsing into whatever the preprocessor produced.
Three structural capabilities set this apart from AST-based C SAST tools:
COPY_INPUT, the taint path survives the expansion and tracks through to the eventual memory operation.#ifdef branches are not collapsed to a single parse path. Gecko reasons over multiple compilation configurations, catching vulnerabilities that only appear under specific build flags, including the category of business logic flaws in AppSec that rule-based tools cannot model.The result for cpp security analysis is a finding set where the macro expansion is part of the evidence, not an obstacle to it. Every reported issue includes the expansion chain that produced the vulnerable construct, giving engineers the context they need to act without manually reconstructing what the preprocessor did.
If your C or C++ codebase uses macros the way most systems code does, the SAST tool reporting zero findings in those areas may not be clean. It may just be blind. Pre-analysis expansion, inter-procedural scope, and multi-configuration coverage aren't optional features for this class of code; they're the baseline for analysis you can actually trust. Book time with the Gecko team to see how this works in practice on a real codebase.
AST-based C SAST tools analyze source after the preprocessor runs, so macros have already rewritten the source and the original structure is gone. A buffer overflow hidden inside a size-calculation macro, or a bounds check that disappears under a release build flag, never appears in the AST at all: the vulnerability has no node to match against, so no rule fires.
You can run it, but accuracy degrades without a compilation database. Tools that ingest compile_commands.json get accurate include paths and predefined macros, which closes part of the gap, but generating that database requires a working build environment that is often unavailable in CI pipelines, cross-compilation setups, or legacy projects. That dependency means C SAST tools built around this approach fail silently on the codebases where accurate analysis matters most.
ZeroPath's AST-based parsing loses context at macro boundaries, which produces false positives and duplicate findings when analyzing C/C++ macros as a structural consequence of that approach. Gecko builds a compiler-accurate semantic graph that preserves macro invocation sites and expansion context as first-class nodes, so taint flows through macro-defined constructs remain traceable instead of collapsing into whatever the preprocessor produced.
Compiler-accurate analysis resolves the full post-expansion code (types, call chains, and conditional compilation paths) so every finding reflects what the binary actually does, not a simplified parse of the original source. In practice, buffer overflows inside size-calculation macros, integer truncation in type-casting macros, and security checks that vanish under specific build flags all become visible instead of silently dropping out of the analysis graph.
Look for a tool that reasons over multiple compilation configurations instead of collapsing #ifdef branches to a single parse path. Any tool that picks one build variant arbitrarily will miss entire vulnerability classes that only appear under specific flags: a structural gap, not a tuning problem, and one that no ruleset adjustment can recover.
Jeevan Jutla
Co-founder & CEO
JJ joined GCHQ as a teenager, working on security research and exploit development, and scored the highest mark on its reverse engineering and binary exploitation aptitude test ever recorded. The record still stands. He went on to lead security tool development for Binance’s eight-person red team and led the recovery of $500K stolen by North Korean state hackers, the largest recovery of stolen funds at the time.
The latest news, technologies, and resources from our team.
How Cal.com consolidated noisy security tooling into one continuous, context-aware pull request security program with Gecko.
Gecko Security
See what actually changed in the OWASP Top 10 for 2026, from merged SSRF and XXE categories to new supply chain risks and scanner coverage gaps.
Jeevan Jutla
Gecko Security uncovered CVE-2026-21894 in August 2026, an n8n authorization bypass with CVSS 8.8. See why static tools missed it and how to remediate it.
Jeevan Jutla
Security misconfiguration is OWASP A05 for a reason. Learn how deployment context determines exploitability and how to fix gaps in August 2026.
Jeevan Jutla
How do modern AppSec vendors actually compare? This July 2026 capability map covers SAST, DAST, SCA, business logic flaws, and cross-service
Gecko Security
Break down your AppSec stack: what SAST, DAST, SCA, IAST, and pen testing each see — and what they miss. Updated July 2026 by Gecko Security.
Gecko Security
Occasional updates, new content, and insights. No spam; unsubscribe anytime.