C
CIFP

CEL Expression Reference

Complete reference for firewall rule expressions.

CIFP uses Google's Common Expression Language (CEL) for firewall rule expressions. Every expression must evaluate to a bool.

Available Variables

VariableTypeExample value
request.methodstring"GET"
request.urlstring"https://api.openai.com/v1/models"
request.hoststring"api.openai.com"
request.pathstring"/v1/models"
request.headersmap<string,string>{"content-type": "application/json"}
request.body_samplestringFirst 4 KB of request body (UTF-8, lossy)
client.ipstring"203.0.113.45"
client.usernamestring"proxy-abc123-u1a2b3"

Operators

OperatorMeaningExample
==Equalsrequest.method == "POST"
!=Not equalsrequest.host != "localhost"
&&ANDrequest.method == "GET" && request.host == "api.openai.com"
||ORrequest.method == "GET" || request.method == "HEAD"
!NOT!request.path.startsWith("/admin")
inList membershiprequest.method in ["GET", "POST"]

String Functions

FunctionExample
.startsWith(prefix)request.path.startsWith("/v1/")
.endsWith(suffix)request.url.endsWith(".json")
.contains(substr)request.url.contains("api.github.com")
.matches(regex)request.host.matches("^(api|www)\.example\.com$")
.size()request.path.size() < 200
.lower()request.method.lower() == "get"

Header Access

Headers are a map<string,string>. Keys are lowercase. Access them with bracket notation:

bash
# Check Content-Type
request.headers["content-type"] == "application/json"

# Check if header exists
"x-custom-header" in request.headers

# Safe access with has()
has(request.headers.authorization)

Numeric Comparisons

bash
# Deny requests with large bodies (over 1 MB)
int(request.headers["content-length"]) > 1048576

Full Rule Examples

bash
# Allow only GET to api.openai.com
request.host == "api.openai.com" && request.method == "GET"

# Allow any method to openai or anthropic
request.host in ["api.openai.com", "api.anthropic.com"]

# Deny requests that look like exfiltration (body contains base64 of something large)
request.body_sample.size() > 2048 && request.method == "POST"

# HITL (human review) for any DELETE
request.method == "DELETE"

# Allow requests from internal IPs only
client.ip.startsWith("10.") || client.ip.startsWith("192.168.")

# Deny all — catch-all at priority 9999
true

Compile Errors

CEL expressions are compiled when you create or update a rule. If your expression is invalid, the API returns a 400 with the CEL compile error. Rules with compile errors are never stored.