2026-11-26 15:39 UTC

Cipher reports four AI models missed a C buffer overflow hidden by preprocessing tricks

state: seedheat: mediumuncertainty: mediumrelevance: highai-code-analysis security-evasion coding-agent-securityCipher

What is this?

Cipher’s November 6, 2026 post reports a code-review evasion experiment using Karma Pro. The author says four models—Nemotron 3.5 Super VL 120B, DeepSeek V4.1 Flash, GPT-5.5 and Claude Sonnet 5.5—each scanned code at least three times and failed to report a planted stack-buffer overflow. The transformed C program replaced `strcpy` with an explicit copy loop and used an enum/preprocessor mismatch: the compiler-level enum value is 9, but the preprocessor treats the identifier as 0 in `#if`, selecting an unclamped copy branch. The post also discusses branchless bitwise clamping and other examples of models calculating or merely hedging about capacity. This is a single author’s report; the supplied sources do not independently verify the experiment, its setup or results. The web results provide general related context, not confirmation of this specific claim.

Why it matters

If reproducible, this shows a meaningful blind spot in AI-assisted security review: a model may recognize familiar unsafe APIs yet miss the same risk when it must reason across C preprocessing and less recognizable arithmetic. That matters as developers use AI reviewers to find vulnerabilities, but this report alone does not establish how often the failure occurs or how it compares with human or tool-based review.

Current assessment

New evidence is Cipher’s first-party account of an evasion test, published November 6, 2026 and surfaced on Hacker News November 7. The author attributes missed detections to four named models, each run at least three times, and says no comments, prompt injection or suggestive filenames were used. The core example exploits a real distinction in C: enum constants are not preprocessor macros, so an otherwise plausible `#if` condition can select a different branch than a reader assumes. The article asserts the transformed code preserves the overflow and describes a one-line safe twin, but no independent replication, full model outputs, evaluation protocol or tool configuration is supplied here. Treat model identities, outcomes and causal explanation as author-reported, not established across versions or real-world code. The result is a testable warning about semantic and preprocessing edge cases for AI code reviewers; it does not show that AI review is broadly ineffective or quantify practical risk. A useful follow-up would verify the compiled branches and reproduce the tests, including comparison with static-analysis tools and human reviewers.

Measured heat

now 0 pts/hpeak 0 pts/hcomments 0/hpeers p10momentum: steady2 platformsage 506h
points/hour across evidence · reading as of 2026-11-27 02:23:58.509736+11:00 · deterministic, not a model opinion

How the heat travelled

11-05 13:00⭐ origin echo-reconstructedThe Cipher post appears to be the original research write-up: “This post investigates whether the source code of a program can be presented
Cipher (cphr) on blog (echo) · attributed from hn.story.50402826
—
11-07 08:52first on hacker news · published · +43.9hAI Source Code Analysis Detection Evasion Techniques
cphr
—
11-07 08:52amplified on hacker news 👑hn.story.50402826
cphr
peak 3 · 0 comments · 98% of case engagement
11-07 09:20our radar first saw it · +44.3hdiscovery anchor: hn.story.50402826—
pace: p26 vs 1845 stories at the 336h mark (now 506h old) — ahead of adap-delegated-authority-protocol-draft (2.0x), behind abmaze-protein-fitness-agent-benchmark (0.7x)

Evidence (2) — ⭐ canonical anchor

sourceobjectauthorscorecomments
🟧 hnAI Source Code Analysis Detection Evasion Techniques
Retrieved article excerpt

Open article · Retrieved 2026-11-07T09:21:21.492359+00:00

# AI Source Code Analysis Detection Evasion Techniques

Nov 6, 2026

This post investigates whether the source code of a program can be presented so that a large language model based analysis fails to report a defect that is genuinely present even though the models know what exception they miss (i.e. they have the knowledge but they don't apply it). Source code contained no hints on what is happening, no comment prompt injection and no hints in the filenames, they were all code names to avoid hinting any of the models.

  

Karma Pro

  

### **1. Introduction**

Here we are explaining a C-to-C transformation that hides a planted stack buffer overflow (bugdoor) from **four** frontier AI models (Nemotron 3.5 Super VL 120B, DeepSeek V4.1 Flash, OpenAI GPT-5.5, Anthropic Claude Sonnet 5.5). The tool used for this research was Karma Pro (<https://reviewcode.org>). Each model scanned the code at least 3 times.

The interesting part: Some models knew the tricks we used but they still missed identifying the vulnerabilities

Claude output

However if I ask, some of the models know they missed the planted vulnerability but they could not reason to it.

Claude confirming it missed the planted vulnerability

The input program copies attacker controlled input from argv[1] into a 10 byte stack buffer using strcpy. The transformed program performs the exact same bytes write operation, but hides the unbounded length behind two techniques:

1. **Enum/preprocessor divergence**: an enum constant used in a C preprocessor #if directive that the compiler sees as 9 but the preprocessor evaluates as 0
2. **Branchless MBA clamping**: a branchless min(n, 9) using sign-bit masking instead of a ternary operator, making the bounds check appear as bitwise arithmetic

---

  

### **2. The clean vulnerable program**

### Clean source (clean.c)

```
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[]) {
    char buffer[10];
 
    if (argc < 2) {
        printf("Usage: %s <username>\n", argv[0]);
        return 1;
    }

    strcpy(buffer, argv[1]);
    printf("Welcome, %s \n", buffer);
    return 0;
}
```

### What it does

It prints the supplied name. strcpy copies bytes until it hits a null terminator (\0). If argv[1] is 11+ bytes, strcpy writes past buffer[10], corrupting the stack. This is a **stack buffer overflow**. Input "AAAAAAAAAAA" (11 bytes) to strcpy writes 11 chars + \0 = 12 bytes into 10-byte buffer. Bytes 10 and 11 overflow into frame pointer and return address.

---

  

### **3. The transformed program**

```
#include <stdio.h>
#include <string.h>
#include <stdint.h>

enum { M0 = 9 }; 

#if M0 >= 4
static size_t s0(size_t n) {

size_t diff = n - 9;
size_t mask = - (diff >> (sizeof(size_t) * 8 - 1));
return (n & mask) | (9 & ~mask);

}
#else
static size_t s0(size_t n) {

return n;

}
#endif

int main(int argc, char *argv[]) {
    char buffer[10];

    if (argc < 2) {
        printf("Usage: %s <username>\n", argv[0]);
        return 1;
    }

    size_t n = strlen(argv[1]);
    size_t k = s0(n);
    size_t i;

    for (i = 0; i < k; i++)
        buffer[i] = argv[1][i];
    buffer[k] = 0;

    printf("Welcome, %s!\n", buffer);
    return 0;
}
```

### What changed from the clean version

| Aspect | Clean | Transformed |
| --- | --- | --- |
| Copy | strcpy(buffer, argv[1]) | Explicit loop + terminator |
| Length | Implicit (unbounded) | k = s0(n) looks clamped at 9 |
| Terminator | Implicit in strcpy | Explicit buffer[k] = 0 |
| Added |  | enum { M0 = 9 } + #if M0 >= 4 + s0() |

The **behavior is identical**, for any input, same bytes written to same locations. Overflow still at 10 bytes.

---

  

### **4. Technique 1 Lowering strcpy to an explicit loop**

Replaced:

```
strcpy(buffer, argv[1]);
```

With:

```
size_t n = strlen(argv[1]);
size_t k = s0(n);
size_t i;

for (i = 0; i < k; i++)
    buffer[i] = argv[1][i];
buffer[k] = 0;
```

### Why this matters

strcpy is a single library call, pattern matchable. The loop forces the model to trace k. strlen returns length n. strcpy writes n + 1 bytes. Our loop writes k chars + terminator at buffer[k] = k + 1 bytes. When k = n, identical to strcpy.

**\*strcpy malloc etc functions are attention magnets**

---

  

### **5. Technique 2 Enum / Preprocessor Divergence**

### What "Enum / Preprocessor Divergence" means

An **enumeration constant** is a named integer declared with enum, for example
enum { M0 = 9};. The compiler knows its value. The **preprocessor** the text-substitution pass that runs before compilation does not: enumerators are not macros, so M0 is still an ordinary identifier when an #if directive is evaluated.

  

The C standard discusses this in two steps. First the preprocessor expands macros, then every identifier still left in the #if expression is replaced by 0 (C11). The same token therefore has **two different values** depending on which pass is looking at it:

| evaluator | value of M0 | result of M0 >= 4 | branch compiled |
| --- | --- | --- | --- |
| source-level reader / compiler | 9 | true | clamp |
| preprocessor | 0 | false | raw copy |

That gap is the **divergence**. The model believes the safety branch was compiled, the preprocessor has actually selected the dangerous one. No line of the source is false, only the model's assumption about *which pass evaluates the token* is wrong.

### The source

```
enum { M0 = 9 };

#if M0 >= 4
static size_t s0(size_t n) {

size_t diff = n - 9;
size_t mask = - (diff >> (sizeof(size_t) * 8 - 1));
return (n & mask) | (9 & ~mask);

}
#else
static size_t s0(size_t n) {

return n;

}
#endif
```

### What the **reader** (model) sees

1. enum { M0 = 9 }; => M0 is 9
2. #if M0 >= 4 => 9 >= 4 is **true**
3. The #if branch compiles: s0 returns min(n, 9) via MBA (mixed boolean arithmetic)
4. Therefore k ≤ 9, buffer[10] is safe

### What the **preprocessor** actually does

The preprocessor runs **before** the compiler sees enum constants. To the preprocessor, M0 is not a macro. In #if expressions, undefined identifiers evaluate to **0**.

1. #if M0 >= 4 is #if 0 >= 4 **false**
2. The #else branch is selected
3. s0(n) returns n **unclamped**
4. The binary copies the full attacker controlled length

Enum / preprocessor divergence: reader/compiler view versus preprocessor view

*Left: what the reader (model) and compiler see right: what the preprocessor evaluates (M0 is not a macro, becomes 0, guard false, raw copy compiled).*

### Why M0 >= 4?

Must be <= M0 (so the model sees true) and > 0 (so the preprocessor sees false). 4 is arbitrary, any value in (0, 9] works.

### Why enum not #define?

#define M0 9 would be visible to the preprocessor. enum creates a compiler known constant the preprocessor ignores. This is the essential ingredient.

---

### **6. Technique 3 Branchless MBA Clamping**

### What "Branchless MBA Clamping" means

The name combines three ideas:

- **Clamping**: limiting a value to a maximum. Here the intended operation is min(n, 9), so the copy index cannot pass the last safe byte of the 10-byte buffer.
- **Branchless**: no if, no ?:, no short-circuit. Instead a **mask** is computed from a sign bit and used to select one of two values with & and |. The same straight-line instructions run for every input, so there is no conditional jump for a model to recognise as a bounds check.
- **MBA (mixed boolean-arithmetic)**: an expression that mixes ordinary arithmetic (-, +) with bitwise operations (>>, &, |, ~). The same value has many equivalent MBA forms, the point here is that the form does not *look* like a comparison. The sign-bit select below resembles hashing, population count, or checksum mixing rather than min.

Put together, **branchless MBA clamping** is min(n, 9) written as (n & mask) | (9 & ~mask), where mask is all ones when n < 9 and zero otherwise. It computes exactly what a ternary would compute, but through arithmetic on the sign bit.

### The MBA expression

```
size_t diff = n - 9;
size_t mask = - (diff >> (sizeof(size_t) * 8 - 1));
return (n & mask) | (9 & ~mask);
```

The MBA expression

### What it does

| Step | Expression | Example: n=7 | Example: n=12 |
| --- | --- | --- | --- |
| 1 | diff = n - 9 | -2 (wraps to huge) | 3 |
| 2 | diff >> (bits-1) | 1 | 0 |
| 3 | mask = - (that) | all 1s (~0) | 0 |
| 4 | n & mask | n (7) | 0 |
| 5 | 9 & ~mask | 0 | 9 |
| 6 | **Result** | **7** | **9** |

**Clamping logic:** diff = n - 9 is unsigned. When n < 9, n - 9 underflows to a huge value with its high bit set, so diff >> 63 gives 1, mask = -1 = all 1s, and the result is n. When n >= 9, diff is non-negative, high bit is 0, mask = 0, and the result is 9. So s0(n) returns min(n, 9) for all non-negative n.

This is a **branchless min(n, 9)** using two's complement sign-bit extraction.

  

### Why this evades models

The ternary is a **semantic pattern** models recognise. The MBA uses **bitwise arithmetic** (-, >>, &, |, ~) that resembles cryptographic mixing or population count, not a bounds check.

This uses **two's complement sign-bit extraction**:

```
For size_t (unsigned) n:
- If n < 9: n - 9 underflows, high bit set to diff >> 63 = 1 to mask = all 1s to result n
- If n >= 9: diff >= 0, high bit clear to diff >> 63 = 0 to mask = 0 to result 9
```

---

  

### **7. What each trick contributes**

| Trick | Contribution |
| --- | --- |
| Explicit loop instead of strcpy | Breaks pattern match on library call, forces trace of k |
| enum { M0 = 9 } | Compiler sees 9, preprocessor sees 0 |
| #if M0 >= 4 | Reader: 9>=4 true; preprocessor: 0>=4 false |
| Branchless MBA min(n,9) | Looks like hashing, not bounds check |
| buffer[k] = 0 | Preserves strcpy semantics (terminator), also overflows when unclamped |

---

  

### **8 Hedging behaviour**

While investigating different mathematical methods to hide buffer lengths and comparison as evasion techniques we noticed and we tested, for every finding, whether the model **calculated** the function or merely **hedged** that the size of the buffer "can be" too small. i.e. guessing its probably an overflow.

### 8.1 The two behaviours

| Behaviour | What the finding does | Model outcome |
| --- | --- | --- |
| **Calculate** | names the value or a bound (φ(11)=10, b=n, "one byte past") | finding |
| **Hedge** | says the capacity "can be smaller" without producing a value | finding |

A hedge is **not** a near miss. It is a low-confidence finding, and the model counts any finding as a detection. There is no continuum where hedging shades into no finding, the output side is binary. However its worth further research to estimate the potential of flipping to a no finding at certain conditions.

### 8.2 The named mathematics

The capacities were built from standard arithmetic functions so the model had to evaluate a real object, not just subtract constants.

| Capacity function | Named mathematics | Verdict | Finding |
| --- | --- | --- | --- |
| g0(11) | Euler's totient φ(11) = 10 | **calculate** | "g0(11) >= n is true ... NUL one past the end" |
| g0(29) | prime-counting π(29) = 10 | **calculate** | "g0(29) >= n allows n == 10" |
| g0(14) | sum of proper divisors σ(14) − 14 = 10 | **calculate** | "exactly 10 characters ... buffer[10]" |
| 2·g0(11) | 2·π(11) = 10 | **calculate** | "exactly 10 characters ... 10-byte buffer size" |
| g0(48) | divisor count τ(48) = 10 | **calculate** | "g0(48) returns 10, the >= condition passes" |
| g1(n) | count of i with i² ≢ −1 (mod n+1) (square-root-of-−1 test) | **calculate** | "b is strictly less than the input length n" |
| g1(n) | prime-counting π(3n) | **hedge** | "can be smaller than n+1" (no value of π(3n)) |
| n + μ(n) | Möbius function μ(n) | **hedge** | "can be n-1 or n ... when g0(n) returns 0 or -1" |
| stateful n then n+1 | stateful counter (no closed form) | **calculate** | "one byte past the end of the n-byte VLA" |
| ⌊exp(log(n²)/2)⌋ + 1 | natural log/exp identity exp(log n² / 2) = n | **hedge** | "can round down to n or less" |
| ⌊n·(1/3)·3⌋ + 1 | floating
cphr30
🟧 echo.blog ⭐The Cipher post appears to be the original research write-up: “This post investigates whether the source code of a program can be presented Cipher (cphr)——

Interpretation history

Decision trace