Jennifer facing hostile input

Jennifer

Caps, bounded parsing, deadlines, server defaults, and what decks promise.

November 2026, by @mplx.
Based on Jennifer 0.27.0

Powered by Jennifer's Cantrip - Markdown into slide decks, https://github.com/jennifer-language/cantrip
1 / 20

The script is trusted, the input is not

2 / 20

What counts as a security bug, and where to report it

A bug: hostile data harms a correct programNot a bug
A module puts a caller value on the wire unescaped (CRLF, cookie attributes)fs, net, os, sql, meta reaching the host
An attacker-shaped document crashes uncatchably or eats all memoryAn explicit opt-in such as TLS skipVerify
Weak crypto: guessable randomness, timing leaks, algorithm confusionA program that passes raw input to os.run

Interpreter and stdlib: privately to security@jennifer-lang.dev (SECURITY.md). A @deckyard deck: its repository's Security tab.

3 / 20

413 bytes that want to be a billion nodes

def doc as string init "a: &a [x, x, x, x, x, x, x, x, x, x]\n" +
    "b: &b [*a, *a, *a, *a, *a, *a, *a, *a, *a, *a]\n" +
    # ... c to h, each one ten aliases of the line before ...
    "i: &i [*h, *h, *h, *h, *h, *h, *h, *h, *h, *h]\n";
try {
    yaml.decode($doc);
} catch (e) {
    io.printf("%d bytes: %s\n  %s\n", len($doc), $e.kind, $e.message);
}
413 bytes: limit
  yaml.decode: document expands to too many nodes (limit 2097152);
  possible alias bomb
4 / 20

Headers that lie, and a zip bomb

def png as bytes init forgedPng(100000, 100000);   # header rewritten
try { images.decode($png); } catch (e) { report(len($png), $e); }

def zeros as bytes init binary.make(64 * 1024 * 1024);
def zip as bytes init compress.pack("gzip", $zeros);
try {
    compress.unpack("gzip", $zip, 1048576);
} catch (e) { report(len($zip), $e); }
75 bytes: limit
  images.decode: a 100000x100000 image exceeds the 67108864-pixel limit
131573 bytes: limit
  compress.unpack: decompressed size exceeds the 1048576-byte limit
5 / 20

The caps you get without asking

WhereDefault capLower it with
json / toml / xml / asn11000 levels, shared node budgetjson.decodeWith
yaml128 levels, 4 MiB input
images.decode64 MpxmaxPixels argument
compress.unpack, net.readAll256 MiBmaxBytes argument
http client64 MiB body, 1 MiB headrequestWith maxBytes
httpd / web server10 MiB body, 64 KiB head, 256 in flighthttpd.Options
call depth10000 nested calls

Every one is kind "limit"; the server answers 413 / 431 instead.

6 / 20

Your own caps: the input's size, not the machine's

images.decode($upload, 4000000);                        # 4 Mpx
compress.unpack("gzip", $raw, 16777216);                # 16 MiB
net.readAll($conn, 65536, 5000);                        # 64 KiB, 5 s
http.requestWith("GET", $url, {}, "", 5000, 1048576);   # 5 s, 1 MiB
def opts as json.DecodeOptions init
    json.DecodeOptions{maxDepth: 20, maxNodes: 10000};
json.decodeWith($text, $opts);
limit | json.decodeWith: nesting exceeds 20 levels at line 1, column 21
7 / 20

A cap must survive your wrappers, so test it

# config_test.j, beside a config.j whose load() wraps json.decode
func deepConfig() { load(strings.replicate("[", 5000)); }
func brokenConfig() { load("[1, 2"); }

func testCapStaysLimit() {
    testing.assertThrows("deepConfig", "limit");
}
func testMalformedIsConfig() {
    testing.assertThrows("brokenConfig", "config");
}
FAIL testCapStaysLimit (0 ms)
     [assertion] config_test.j:8:5 assertThrows: "deepConfig" threw
     kind "config", expected "limit"
8 / 20

Malformed bytes: the module's kind, not "runtime"

def jpeg as bytes init images.encode("jpeg", images.create(64, 64));
def sof as bytes init encoding.fromText("hex", "ffc0");   # SOF0
def at as int init binary.indexOf($jpeg, $sof);
def cut as bytes init $jpeg[..$at + 3];   # mid header
try {
    pdf.loadImage("Logo", $cut);
} catch (e) {
    io.printf("%s\n%s\n", $e.kind, $e.message);
}
pdf
loadImage: 'Logo' is a malformed image: binary.readUint: 2-byte value
  at offset 138 runs past the end of 139 bytes
9 / 20

Your own parser: check before you read

func records(b as bytes) {
    def out as list of bytes;
    def at as int init 0;
    while ($at < len($b)) {
        if (len($out) == MAX_RECORDS) { tooMany(); }
        need($b, $at, 2);
        def n as int init binary.readUint("be", $b, $at, 2);
        need($b, $at + 2, $n);
        $out[] = $b[$at + 2..$at + 2 + $n];
        $at = $at + 2 + $n;
    }
    return $out;
}
10 / 20

Hostile input meets records

func need(b as bytes, at as int, n as int) {
    if ($at + $n > len($b)) {
        def left as int init len($b) - $at;
        throw Error{kind: "tlv",
            message: "tlv: {$n} bytes needed at {$at}, {$left} left"};
    }
}
tlv | tlv: 2 bytes needed at 4, 1 left            5 zero bytes
limit | tlv: over 1000 records                    3000 zero bytes
tlv | tlv: 9 bytes needed at 2, 2 left            00 09 01 02

Without need: runtime | binary.readUint: 2-byte value at offset 4 ...

11 / 20

A peer that stalls, a peer that never stops

# fake server: no answer, then a 999999999-byte body
for (def i in 0..2) {
    try {
        http.requestWith("GET", $url, {}, "", 500, 1048576);
    } catch (e) {
        io.printf("%s | %s\n", $e.kind, $e.message);
    }
}
timeout | net.readBytes: read timed out
limit | http: response body exceeds 1048576 bytes
12 / 20

A slow drip beats an idle timeout

def job as task of http.Response init spawn { return fetch($url); };
try {
    task.waitTimeout($job, 2000);
} catch (e) {
    def ms as int init time.unixMillis(time.now()) - $started;
    io.printf("after %d ms: %s\n", $ms, $e.kind);
    task.cancel($job);
}
try { task.wait($job); } catch (e) { io.printf("job: %s\n", $e.kind); }
after 2000 ms: timeout
job: cancelled
13 / 20

The server side: limits answered with a status

def srv as httpd.Server init httpd.listenWith("127.0.0.1:0",
    httpd.Options{maxBodyBytes: 1024, bodyTimeoutMs: 1000});
def worker as task of null init spawn { web.serveOn($app, $srv); };
small  -> 200 got 100 bytes
large  -> 413 request body exceeds the server's limit of 1024 bytes
header -> 431
slow   -> HTTP/1.1 408 Request Timeout

Defaults: 10 MiB body, 64 KiB head, 256 in flight, 60 s for a body, 60 s to answer.

14 / 20

What web does for you at the boundary

web: unhandled handler error: Error{kind: "db", message: "login failed
  for user shelf", file: "web15.j", line: 9, col: 5}
client: 500 500 internal server error
cookie: Path=/; HttpOnly; Secure; SameSite=Lax
15 / 20

Deck capabilities: a label, not a fence

# pragma-jennifer-version: >=0.26.0
use os;
export func shade(name as string) {
    def r as os.Result init os.run(["uname", "-s"]);
    return $name + " on " + $r.stdout;
}
$ jennifer run app.j
build: exec,net,sql
teal on Linux
$ jennifer-tiny run app.j
build:
app.j: runtime error at colors.j:4:29: os.run: external-program ...
16 / 20

Publishing: what is checked, and by whom

StepChecksSkippable
jvc publish, validationscoped name, SemVer, src/<deck>.j, every pragma listed in capabilitiesno
jvc publish, quality gatelint, a passing test overlay per module, docblocks--no-verify
registryyour login, token or CI identity; scope bound to an account id; manifest read at the tag's commit through the forge API; version equals tag; no overwriteno
nobodywhat the code does
17 / 20

Using decks you did not write

18 / 20

Checklist for code that reads hostile input

19 / 20

Read more

Based on Jennifer 0.27.0, November 2026.

20 / 20