Test nginx rewrites for heap overflows

Remote code execution (RCE)Discovery

Written with a model's help from “Needle in a haystack: measuring the impact of two nginx RCEs” on Calif. Read the writeup before relying on it.

Look for rewrite directives in nginx configurations that contain a ? and no flag (like last, break, redirect, or permanent). If the rewrite is followed by a set or if directive that references a capture group (like $1), the configuration may be vulnerable to a heap overflow. The overflow occurs when the captured group contains bytes that expand under URI escaping (like + becoming %2B). To confirm, send a request with a URI that triggers the rewrite and contains escapable characters in the captured portion. A heap overflow may be indicated by a crash or unexpected behavior.

Follow #nginx, #rce or #rewrite-engine for new tips like this one, on your notifications page and, if you choose, in a daily or weekly email.

Comments

No comments yet.