<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Behzad Soltanpour</title>
    <description>The latest articles on DEV Community by Behzad Soltanpour (@behzadsp).</description>
    <link>https://dev.to/behzadsp</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1895615%2F4c71028f-d90a-4416-b19d-232113421327.jpeg</url>
      <title>DEV Community: Behzad Soltanpour</title>
      <link>https://dev.to/behzadsp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/behzadsp"/>
    <language>en</language>
    <item>
      <title>A semicolon walked past our WAF: Cloudflare path rules vs. Traefik path sanitizing</title>
      <dc:creator>Behzad Soltanpour</dc:creator>
      <pubDate>Tue, 01 Dec 2026 09:46:18 +0000</pubDate>
      <link>https://dev.to/behzadsp/a-semicolon-walked-past-our-waf-cloudflare-path-rules-vs-traefik-path-sanitizing-383a</link>
      <guid>https://dev.to/behzadsp/a-semicolon-walked-past-our-waf-cloudflare-path-rules-vs-traefik-path-sanitizing-383a</guid>
      <description>&lt;p&gt;We had a Cloudflare custom rule that blocked an admin area for every IP outside an allowlist. It looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vcl"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;http.host eq &lt;span class="s2"&gt;"app.example.com"&lt;/span&gt;
 and starts_with&lt;span class="o"&gt;(&lt;/span&gt;lower&lt;span class="o"&gt;(&lt;/span&gt;http.request.uri.path&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;"/admin"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
 and not ip.src &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$admin_ips&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It worked. Requests to &lt;code&gt;/admin/login.php&lt;/code&gt; from outside the office got a Cloudflare 403. The usual tricks were caught too: &lt;code&gt;//admin/&lt;/code&gt;, &lt;code&gt;/./admin/&lt;/code&gt;, &lt;code&gt;/%61dmin/&lt;/code&gt; and &lt;code&gt;/ADMIN/&lt;/code&gt; all got 403, because the zone normalizes URLs before rules run and the rule lowercases the path.&lt;/p&gt;

&lt;p&gt;Then this one got a 200 and the real admin login page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://app.example.com/;/admin/login.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why it got through
&lt;/h2&gt;

&lt;p&gt;Two components looked at the same request and disagreed about what the path was.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloudflare&lt;/strong&gt; evaluated the rule against &lt;code&gt;/;/admin/login.php&lt;/code&gt;. That string does not start with &lt;code&gt;/admin&lt;/code&gt;, so the rule did not match. Cloudflare's URL normalization collapses duplicate slashes and resolves &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;..&lt;/code&gt; segments, but it leaves a segment made of a single &lt;code&gt;;&lt;/code&gt; alone. The request went to the origin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Traefik&lt;/strong&gt; sat behind Cloudflare. Since v3.7.18, with &lt;code&gt;sanitizePath&lt;/code&gt; enabled (the default), Traefik resolves a &lt;code&gt;..&lt;/code&gt;, &lt;code&gt;.&lt;/code&gt; or empty segment that carries path parameters the same way as a plain dot segment or a duplicate slash. The migration notes give &lt;code&gt;/foo/.;bar/baz&lt;/code&gt; → &lt;code&gt;/foo/baz&lt;/code&gt; as the example. &lt;code&gt;/;/&lt;/code&gt; is an empty segment with a path parameter, so Traefik turned it into &lt;code&gt;/&lt;/code&gt;, and the backend received:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;GET&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;admin&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;login&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The access log on the origin showed the clean path. Nothing there looked unusual. The only place the &lt;code&gt;;&lt;/code&gt; was visible was Cloudflare's sampled logs for that request, where the path column read &lt;code&gt;/;/admin/login.php&lt;/code&gt; and the mitigation column read "Not mitigated".&lt;/p&gt;

&lt;p&gt;Neither product is doing anything wrong on its own. Traefik's behaviour is documented and intended; collapsing path-parameter segments closes a class of routing tricks inside Traefik. Cloudflare matched the rule exactly as written. The gap only exists when a security decision is made on one representation of the path and the request is then served from another.&lt;/p&gt;

&lt;h2&gt;
  
  
  How we found it
&lt;/h2&gt;

&lt;p&gt;Not from an alert. We were reviewing a day of access logs after other suspicious activity and noticed requests to the admin login from a few hundred rotating IPs, none of them on the allowlist, all of them answered by the origin. The rule existed and was enabled, so the requests should never have reached the origin at all.&lt;/p&gt;

&lt;p&gt;The Ray ID of one of those requests led to Cloudflare's sampled log entry, and the path in it explained everything. Logins did not succeed (the admin accounts use 2FA), but the login page and the login endpoint were reachable from anywhere.&lt;/p&gt;

&lt;p&gt;The lesson we took from it: if a WAF rule is supposed to block a path, look at the origin's logs for that path from IPs the rule should have blocked. A rule that silently doesn't match produces no errors, only traffic you didn't expect to see.&lt;/p&gt;

&lt;h2&gt;
  
  
  The sibling problem: allowlisted prefixes
&lt;/h2&gt;

&lt;p&gt;The same zone had a second rule with an exception. Our deployment pipeline calls an API on an internal tool from CI runners whose IPs change constantly, so the rule let one prefix through for everyone:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vcl"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;http.host eq &lt;span class="s2"&gt;"tool.example.com"&lt;/span&gt;
 and not ip.src &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$office_ips&lt;/span&gt;
 and not starts_with&lt;span class="o"&gt;(&lt;/span&gt;http.request.uri.path, &lt;span class="s2"&gt;"/api/v1/applications/"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look at it with the same eyes. A path like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/api/v1/applications/..;/..;/..;/..;/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;starts with the allowed prefix, so it passes the exception. Cloudflare does not treat &lt;code&gt;..;&lt;/code&gt; as a dot segment, so its normalization leaves the path alone. Traefik treats &lt;code&gt;..;&lt;/code&gt; like &lt;code&gt;..&lt;/code&gt;, so the path resolves upward: &lt;code&gt;/api/v1/applications/..;/..;/..;/..;/&lt;/code&gt; returns the tool's UI, and &lt;code&gt;/api/v1/applications/..;/..;/version&lt;/code&gt; returns &lt;code&gt;/api/version&lt;/code&gt;. Anything outside the prefix, the UI and the rest of the API, was reachable through the exception.&lt;/p&gt;

&lt;p&gt;We fixed this one as soon as we understood the first bypass, and confirmed it afterwards from an allowlisted IP, where the rule doesn't apply and the path reaches Traefik unchanged, just as it did through the old exception. From outside the allowlist, the same paths now return 403 at Cloudflare.&lt;/p&gt;

&lt;p&gt;Prefix exceptions are where this class of bug hurts most, because the attacker doesn't need to dodge the rule. The exception does the work for them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix at Cloudflare
&lt;/h2&gt;

&lt;p&gt;For the blocked path, stop asking "does the path start with &lt;code&gt;/admin&lt;/code&gt;" and ask "does &lt;code&gt;/admin/&lt;/code&gt; appear anywhere in the decoded path":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vcl"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;lower&lt;span class="o"&gt;(&lt;/span&gt;http.host&lt;span class="o"&gt;)&lt;/span&gt; eq &lt;span class="s2"&gt;"app.example.com"&lt;/span&gt;
 and not ip.src &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$admin_ips&lt;/span&gt;
 and &lt;span class="o"&gt;(&lt;/span&gt;lower&lt;span class="o"&gt;(&lt;/span&gt;url_decode&lt;span class="o"&gt;(&lt;/span&gt;http.request.uri.path&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; contains &lt;span class="s2"&gt;"/admin/"&lt;/span&gt;
      or lower&lt;span class="o"&gt;(&lt;/span&gt;url_decode&lt;span class="o"&gt;(&lt;/span&gt;http.request.uri.path&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; contains &lt;span class="s2"&gt;"/admin;"&lt;/span&gt;
      or lower&lt;span class="o"&gt;(&lt;/span&gt;url_decode&lt;span class="o"&gt;(&lt;/span&gt;http.request.uri.path&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; contains &lt;span class="s2"&gt;"/admin%"&lt;/span&gt;
      or ends_with&lt;span class="o"&gt;(&lt;/span&gt;lower&lt;span class="o"&gt;(&lt;/span&gt;url_decode&lt;span class="o"&gt;(&lt;/span&gt;http.request.uri.path&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;"/admin"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;/;/admin/login.php&lt;/code&gt;, &lt;code&gt;/x/..;/admin/login.php&lt;/code&gt; and &lt;code&gt;/admin;/login.php&lt;/code&gt; all contain one of those patterns, whatever the proxy behind Cloudflare does with them afterwards.&lt;/p&gt;

&lt;p&gt;Check what else &lt;code&gt;contains&lt;/code&gt; will catch before you deploy it. Our real admin path also appears inside the name of a public asset folder, so we matched &lt;code&gt;"/admin/"&lt;/code&gt; with the trailing slash rather than &lt;code&gt;"/admin"&lt;/code&gt;, which kept the public folder reachable.&lt;/p&gt;

&lt;p&gt;For the exception, make it refuse anything a downstream proxy might rewrite:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vcl"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;lower&lt;span class="o"&gt;(&lt;/span&gt;http.host&lt;span class="o"&gt;)&lt;/span&gt; eq &lt;span class="s2"&gt;"tool.example.com"&lt;/span&gt;
 and not ip.src &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$office_ips&lt;/span&gt;
 and not &lt;span class="o"&gt;(&lt;/span&gt;starts_with&lt;span class="o"&gt;(&lt;/span&gt;http.request.uri.path, &lt;span class="s2"&gt;"/api/v1/applications/"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
          and not url_decode&lt;span class="o"&gt;(&lt;/span&gt;http.request.uri.path&lt;span class="o"&gt;)&lt;/span&gt; contains &lt;span class="s2"&gt;";"&lt;/span&gt;
          and not url_decode&lt;span class="o"&gt;(&lt;/span&gt;http.request.uri.path&lt;span class="o"&gt;)&lt;/span&gt; contains &lt;span class="s2"&gt;".."&lt;/span&gt;
          and not url_decode&lt;span class="o"&gt;(&lt;/span&gt;http.request.uri.path&lt;span class="o"&gt;)&lt;/span&gt; contains &lt;span class="s2"&gt;"//"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The legitimate CI calls (&lt;code&gt;POST .../&amp;lt;app&amp;gt;/sync&lt;/code&gt;, &lt;code&gt;GET .../&amp;lt;app&amp;gt;&lt;/code&gt;) contain none of those, so they still pass.&lt;/p&gt;

&lt;p&gt;Then test from an IP that is &lt;strong&gt;not&lt;/strong&gt; on the allowlist. That sounds obvious, but it is easy to skip: from the office every variant returns 200 and you learn nothing. A phone on mobile data is enough. Our test list after the change:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/admin/login.php           403
/;/admin/login.php         403
//admin/login.php          403
/./admin/login.php         403
/%61dmin/login.php         403
/ADMIN/login.php           403
/admin;/login.php          403
/x/..;/admin/login.php     403
/admin                     403
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What didn't work: blocking &lt;code&gt;;&lt;/code&gt; at the proxy
&lt;/h2&gt;

&lt;p&gt;We wanted a second layer at the origin that didn't depend on keeping an IP list in two places. We already ran a small Traefik plugin as entry-point middleware on every request, so we added a check: if the raw request target contains &lt;code&gt;;&lt;/code&gt; in its path, answer 400.&lt;/p&gt;

&lt;p&gt;It caught &lt;code&gt;/admin;/login.php&lt;/code&gt;. It did not catch &lt;code&gt;/;/admin/login.php&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The reason is ordering. Traefik's path sanitizing runs before entry-point middleware, and by the time our plugin looked at &lt;code&gt;RequestURI&lt;/code&gt;, the &lt;code&gt;/;/&lt;/code&gt; segment was already gone. &lt;code&gt;/admin;/&lt;/code&gt; survived only because a &lt;code&gt;;&lt;/code&gt; attached to a normal segment is not something sanitizing touches. Traefik's documentation doesn't spell out which representation a middleware sees, and we only learned it by testing. If you try the same thing, test it with a request the sanitizer actually rewrites, not just one containing a semicolon.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not just turn off &lt;code&gt;sanitizePath&lt;/code&gt;?
&lt;/h2&gt;

&lt;p&gt;It's tempting: with sanitizing off, &lt;code&gt;/;/admin/login.php&lt;/code&gt; reaches the backend unchanged, a strict check in the proxy can reject it, and the backend (nginx in our case) would not map it to the admin script anyway.&lt;/p&gt;

&lt;p&gt;Traefik's own migration notes describe &lt;code&gt;sanitizePath: false&lt;/code&gt; as unsafe and meant for legacy clients. It changes path handling for every host behind that entry point, not just the one you are worried about, and any router or middleware that makes decisions on the path would then see unsanitized input. We decided that trading a narrow, understood gap for a broad change in behaviour across every site was the wrong direction, and kept the fix at Cloudflare, where the decision is made.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check your URL normalization scope
&lt;/h2&gt;

&lt;p&gt;While looking into this we found that our zones were not configured the same way. Cloudflare's URL normalization has a scope:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;incoming&lt;/strong&gt;: rules see the normalized URL, the origin gets the original&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;both&lt;/strong&gt;: rules see it and the origin gets it too&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;none&lt;/strong&gt;: no normalization at all&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of our zones was set to &lt;code&gt;none&lt;/code&gt;. On that zone, every path-based rule was matching raw, unnormalized paths, so &lt;code&gt;//&lt;/code&gt;, &lt;code&gt;/./&lt;/code&gt; and percent-encoded variants weren't guaranteed to be caught the way they were elsewhere. It is worth checking every zone that has path-based security rules, because the setting is per zone and easy to leave at whatever it was when the zone was created.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A WAF rule and the proxy behind it each have their own idea of what a path is. If they can disagree, an attacker can choose the version each one sees.&lt;/li&gt;
&lt;li&gt;Prefer &lt;code&gt;contains&lt;/code&gt; on the decoded path over &lt;code&gt;starts_with&lt;/code&gt; for blocking. For allowlisted exceptions, refuse &lt;code&gt;;&lt;/code&gt;, &lt;code&gt;..&lt;/code&gt; and &lt;code&gt;//&lt;/code&gt; explicitly.&lt;/li&gt;
&lt;li&gt;Know your proxy's path rewriting. Traefik 3.7.18+ resolves dot and empty segments that carry &lt;code&gt;;&lt;/code&gt; parameters; other proxies have their own rules.&lt;/li&gt;
&lt;li&gt;Test from outside the allowlist, with the encoded, doubled and parameterized variants, after every rule change.&lt;/li&gt;
&lt;li&gt;Read origin logs for paths that should be blocked. If they show up at all, the rule isn't doing what you think.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Traefik v3 migration notes (path sanitizing changes): &lt;a href="https://doc.traefik.io/traefik/migrate/v3/" rel="noopener noreferrer"&gt;https://doc.traefik.io/traefik/migrate/v3/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Traefik request path security: &lt;a href="https://doc.traefik.io/traefik/security/request-path/" rel="noopener noreferrer"&gt;https://doc.traefik.io/traefik/security/request-path/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cloudflare URL normalization: &lt;a href="https://developers.cloudflare.com/rules/normalization/" rel="noopener noreferrer"&gt;https://developers.cloudflare.com/rules/normalization/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>cloudflare</category>
      <category>traefik</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
