DedSec Security Research ·
Here is a hypothetical. A dynamic scan of a web application returns four results about cross-site request forgery. The first, "Absence of anti-CSRF token", rated medium, is on the change-email form at /account/email: the form has no hidden field that looks like a token. The second, on the change-password form at /account/password, never appears, because that form carries a hidden csrf field and the check considers it protected. The third is on /api/transfer, a JSON endpoint, and the scanner's own note says CSRF does not apply to JSON bodies, so it is closed. The fourth is the login form, flagged for having no token, rated informational, and closed because "the user is not logged in yet, and the session cookie is SameSite=Lax anyway".
As in the earlier posts in this series, each decision rests on the title rather than on what the scanner observed and what that observation can prove. The change-email page submits through JavaScript that sends the token in a request header, and the server rejects any request without it. The form has no field because it does not need one, and the medium is a false positive. The change-password handler checks the token only when the field is present, so a forged form that simply leaves it out goes through. The transfer endpoint parses the body as JSON whatever the Content-Type says, so an ordinary HTML form posting text/plain can send it a JSON document. And in our lab a cross-site login form logged the victim's browser into the attacker's account under every SameSite value we tried, Strict included, because SameSite controls which cookies are sent, and a login request needs none.
This post is for whoever is holding a CSRF finding from a dynamic scan, or a clean result they are about to rely on. It covers:
text/plain forms and preflightIt is the seventeenth post in a series about confirming DAST findings. The earlier ones cover reflected XSS, SQL injection, OS command injection, Nuclei template matches, ffuf content discovery, path traversal, open redirect, SSRF through URL-fetch parameters, XXE, CRLF header injection, Host header injection, HTTP request smuggling, CORS misconfiguration, JWT validation, Arjun parameter discovery and server-side template injection. The nearest neighbour is the CORS post. CORS governs whether a cross-origin page can read a response, while CSRF is about whether it can cause a request, and that post measured the same SameSite behaviour from the reading side. The JWT post is the other neighbour, because a bearer token the application attaches itself is not something a browser sends on an attacker's behalf.
Sources, and how each was checked. We made the measurements below on our test machine on 6 November 2026. It runs Ubuntu 24.04.4 on a virtual machine with two vCPUs of an AMD EPYC 9354P. Every server and the browser ran as a non-root user inside a Linux network namespace whose only interface was loopback. Before each run we checked the isolation: the name example.com did not resolve and a TCP connection to 1.1.1.1 failed. The software was:
http.server and ssl modules, with a self-signed certificate from OpenSSL 3.0.13. It uses no web framework and no CSRF library. Each endpoint's protection is a few lines, written to reproduce one pattern on purpose.app.bank.test is the application. blog.bank.test is a sibling subdomain that serves attacker pages, so it is same-site with the application. evil.test serves the same attacker pages from a different registrable domain, so it is cross-site. All three were served over HTTPS on port 8443 and mapped to 127.0.0.1 by a host-resolver rule passed to the browser.missing-cookie-samesite-strict, with interaction testing switched off.We read the Chromium project's "SameSite Updates" page and its "SameSite FAQ", web.dev's article "Understanding 'same-site' and 'same-origin'", the OWASP Cross-Site Request Forgery Prevention Cheat Sheet as published in the OWASP CheatSheetSeries repository that day, and MDN's Set-Cookie reference from the mdn/content repository, all on 6 November 2026. Every quotation and claim attributed to them below was checked against those copies.
We did not test Firefox, Safari or any other browser, a Chrome profile with third-party cookies restricted, or any browser older than the one named. We did not test any framework's CSRF middleware, any DAST tool's CSRF check, or any Nuclei template other than the one named. We did not test plain-http origins, which the CORS post covers, multipart forms, method-override parameters, cross-site WebSocket hijacking, clickjacking, or CSRF triggered by the application's own JavaScript. The opening scenario is hypothetical. The numbers measure our lab, one browser build and one template, and none of them measures AppSecD or how any product checks for CSRF.
A browser attaches some credentials to a request on its own: cookies, HTTP authentication it has cached, a client certificate. It does this whichever page started the request. Cross-site request forgery is a page on another site using that to make the victim's browser send a request the victim did not intend, with the victim's credentials attached. CWE-352 is the usual classification.
The OWASP cheat sheet puts the consequence plainly: "unprotected target sites cannot distinguish between legitimate authorized requests and forged authenticated requests." The attacker never sees the response. The request is the attack.
So an exploitable CSRF is a conjunction of four things:
Authorization: Bearer header that the application's own JavaScript adds is not attached by the browser to a request another page makes, which is why an API authenticated only that way is not a CSRF target. The JWT post covers where such tokens live.fetch), its method, and whether the attacking page is cross-site or merely cross-origin.A finding that says "no token in the form" speaks to point 2 at most, and only to one way of meeting it.
An origin is scheme, host and port. A site is coarser. web.dev's definition is that websites "that have the same scheme and the same eTLD+1 are considered" same-site. The eTLD+1 is the registrable domain, worked out with the Public Suffix List, and the same article's table marks different ports as "Same-site: ports don't matter". So https://blog.bank.test:8443 and https://app.bank.test:8443 are different origins and the same site. SameSite cookies are about sites. A page on any subdomain of your registrable domain is, for SameSite purposes, you.
Browsers report the relationship in the Sec-Fetch-Site request header: same-origin, same-site, cross-site, or none for a navigation the user started directly. Our lab logged it on every request.
In one browser context we set six cookies on app.bank.test, all Secure and HttpOnly. Two were set first: old_unset, with no SameSite attribute, and old_lax, with SameSite=Lax. We waited 130 seconds and set four more: c_none (SameSite=None), c_lax (Lax), c_strict (Strict) and fresh_unset (no attribute). Chromium's cookie store, read through Playwright, reported both unset cookies as Lax.
We then sent seven kinds of request to an endpoint that only logs what arrives, from a page on evil.test, from a page on blog.bank.test, and from the application itself as a control. The seven were an auto-submitting form POST in the top-level window, a link clicked in the top-level window, a form POST inside an iframe, an iframe loading the URL, an image, a no-cors fetch POST with a text/plain body, and a fetch GET with credentials. The first cross-site request reached the server 0.18 seconds after the fresh cookies were set, and the whole matrix finished within 12 seconds.
c_none and fresh_unset. Not c_lax, although it was just as fresh. Not old_unset, at more than 130 seconds old. Not c_strict.c_none, both explicit Lax cookies, and both unset cookies. Not c_strict.fetch calls): c_none only.evil.test, repeated when fresh_unset was 130 seconds old: c_none only.blog.bank.test: all six cookies on all seven kinds of request, Strict included, with Sec-Fetch-Site: same-site.Three things follow.
A cookie with no SameSite attribute was not the same as an explicit Lax cookie. Both were reported as Lax by the cookie store. Only the one without the attribute rode along on a cross-site POST, and only while it was young. This is the behaviour Chromium documents as "Lax + POST". Its SameSite FAQ says that "a cookie that is at most 2 minutes old will be sent on a top-level cross-site POST request", and calls it "purely a temporary solution" that "will be removed in the future". Its update log, in an entry dated 1 November 2019, says the intervention applies to "cookies that don't specify a SameSite attribute", and that "Normal" Lax cookies, meaning ones with the attribute set, "are not sent on cross-site POST requests". MDN's Set-Cookie reference describes the same two-minute allowance. We observed it in Chrome 153 on 6 November 2026. We measured one fresh age, under a second, and two old ages, 130 seconds for old_unset and for fresh_unset in the repeat, not the boundary.
The practical consequence is about timing. The two minutes after a cookie is set are the two minutes after the user logs in, which is when the user is active. A forged POST that arrives in that window, against an application whose session cookie has no SameSite attribute, carries the session. We measured that end to end below.
Lax let top-level GET navigations through. That is what Lax is meant to do, so that following a link into a site keeps you logged in. It is also why a state change on GET is not protected by Lax. The OWASP cheat sheet calls this "the single most common way SameSite-based defenses fail in practice"; that is OWASP's assessment, not something we measured.
Same-site meant every cookie. Nothing in SameSite distinguishes blog.bank.test from app.bank.test. Any subdomain that can be made to serve an attacker's page, through a dangling DNS record, an XSS on a marketing site, a user-content host or a forgotten staging box, defeats SameSite entirely, Strict included.
Two caveats about the browser. Our headless context attached SameSite=None cookies in every third-party position we tried. A Chrome profile that restricts third-party cookies, or a browser that partitions or blocks them, may not send c_none from an iframe, an image or a fetch. We did not test that. And MDN's reference says only that "some browsers" use Lax as the default, while the OWASP cheat sheet says that "Chromium-based browsers treat cookies without a SameSite attribute as Lax, but Firefox and Safari do not". We did not test that either. If it holds, a user of such a browser gets no SameSite protection for a session cookie that has no attribute, although a third-party cookie restriction may still keep the cookie off some subresource requests.
The second part of the lab isolates the token logic. Alice's session cookie was set with SameSite=None, so that the browser would attach it to every cross-site request and the server's check would be the only thing deciding. That is the position of any application whose session cookie has to be None, for example one embedded in a partner's site. Each endpoint changes the logged-in user's email address. Each form page renders the way the pattern implies. A page on evil.test submitted an auto-posting form to each one.
csrf field. A cross-site POST with csrf=garbage executed.csrf field. With csrf=garbage the server returned 403. With the field left out, the POST executed. This is the pattern in the opening scenario: the check is if "csrf" in form and form["csrf"] != expected.csrf field. The server kept one pool of every token it had issued and accepted any of them. With csrf=garbage it returned 403. The attacker logged in as a second user, Mallory, read Mallory's own token from the response, and put it in the forged form. That executed against Alice.fetch and an X-CSRF-Token header. A cross-site form POST got 403, because a form cannot set a header. A cross-site fetch that set the header triggered a preflight: the server logged only an OPTIONS request, without cookies, answered it with no CORS headers, and the POST was never sent. The page saw TypeError: Failed to fetch.csrf field. A cross-site POST with a wrong token got 403, and so did the same POST from the sibling subdomain. The application's own form, submitted from the same origin, executed.Sec-Fetch-Site is present and is neither same-origin nor none, falls back to comparing Origin when Sec-Fetch-Site is absent, and accepts the request when both are absent. The cross-site POST got 403 with Sec-Fetch-Site: cross-site, and the sibling's POST got 403 with same-site.A check that decides by looking for a hidden field with a token-like name would read these seven forms like this. Fields are present on (b), (c), (d) and (j). Of those, only (j) resisted a forged request. Fields are absent on (a), (h) and (k). Of those, only (a) was exploitable. So field presence agreed with what the browser could actually do on 2 of the 7, (a) and (j). That count describes a lab built to contain these patterns, one of each, and says nothing about how often each pattern occurs in real applications. What it does show is that the field and the protection are different things. A field is how a token gets from the server into a form. The protection is a comparison on the server, and nothing in the HTML shows it.
Two more endpoints implement the "double-submit" pattern. The server sets the token in a cookie, and the form must send the same value as a field. The server compares the two and keeps no state.
csrf. From evil.test, a forged form with csrf=attackerval got 403: the attacker cannot set or read a cookie on bank.test. Then a page on blog.bank.test responded with Set-Cookie: csrf=attackerval; Domain=bank.test; Path=/i; Secure; SameSite=None, and submitted a form with csrf=attackerval to /i/email. The browser stored the cookie, and the request carried csrf=attackerval first and the application's own csrf cookie second, consistent with the cookie with the longer path being listed first. Our server compared against the first csrf in the header and the action executed. A server that reads the last duplicate instead would have compared against the application's own cookie. Which one a framework reads is a property of the framework, so this is a question to answer for the stack in front of you.__Host-csrf. The sibling sent the same Set-Cookie with the name __Host-csrf. The request that followed carried only the application's own __Host-csrf cookie, and the server returned 403. MDN's reference says cookies with the __Host- prefix "must have a path of / (meaning any path at the host) and must not have a Domain attribute", so a sibling cannot write one that the application will receive.The OWASP cheat sheet marks the naive pattern as discouraged, saying it "is bypassable by an attacker who can write cookies on the target domain (e.g., via a vulnerable sibling subdomain, DNS takeover, or plaintext-HTTP cookie injection on a non-__Host- cookie)", and recommends a signed token bound to the session.
A JSON API is often assumed to be immune, because a form cannot send application/json. Whether that holds depends on what the server does with a body that arrives with a different Content-Type. Two endpoints, both with Alice's SameSite=None session:
application/json.An HTML form with enctype="text/plain" sends each field as the name, an equals sign and the value, followed by a carriage return and line feed. The trick is a single field whose name is {"email":"[email protected]","pad":" and whose value is "}. The body that arrived was {"email":"[email protected]","pad":"="} followed by the line ending, with Content-Type: text/plain.
text/plain form to (e1): 403, content type text/plain.text/plain form to (e2): executed. Python's JSON parser accepted the trailing line ending as whitespace.no-cors fetch to (e2) with a text/plain JSON body: executed. The page saw an opaque response with status 0, so the attacker learns nothing, and does not need to.no-cors fetch to (e1) that set Content-Type: application/json: the header did not survive. The request arrived as text/plain;charset=UTF-8, the type a string body gets by default, and got 403. A no-cors request is limited to CORS-safelisted request headers, and application/json is not a safelisted Content-Type value; we observed the effect and did not re-read the Fetch standard's wording for this post.cors fetch to (e1) with Content-Type: application/json: the server logged an OPTIONS preflight without cookies, and nothing else. The page saw TypeError: Failed to fetch.So the protection for (e1) came from two places: the server refused bodies it would not parse as JSON, and the browser would not send the JSON Content-Type cross-site without a preflight the server did not approve. Remove either and it is gone. (e2) removes the first. A CORS policy that reflects the origin with credentials removes the second, which the CORS post measured. That post also notes, from body-parser's source rather than from a test, that Express's usual JSON parser leaves a text/plain body unparsed by default. That is a parser default, not a CSRF control, and a handler that reads the raw body or a parser configured for every type gives it up.
Endpoint (f) changes the email address on a GET with the new address in the query string, with no token. We logged Alice in with each of three session cookies in turn and attacked it, and endpoint (a), from both attacker hosts.
SameSite=Lax: the cross-site form POST to (a) arrived without the cookie and was refused. A cross-site link to (f) carried the cookie and executed. A cross-site image pointing at (f) arrived without it. From the sibling subdomain, the POST to (a) and an image pointing at (f) both executed.SameSite=Strict: every cross-site attempt arrived without the cookie, including the link. Both attempts from the sibling executed.With no token anywhere, SameSite was the whole defence, and each value left a specific gap: Lax left GET navigations and the first two minutes after login if the attribute was omitted, and every value left the sibling subdomain.
The login form is where "no token" findings are most often dismissed, on the grounds that the user is not authenticated yet. The attack runs the other way. The attacker logs the victim's browser into the attacker's own account. The OWASP cheat sheet gives the example of a victim who then enters card details into what they believe is their own shopping account. Anything the victim does afterwards, a search history, a saved document, a linked payment method, lands in an account the attacker can read.
Our login endpoint takes a username and password, creates a session, and sets the session cookie with a SameSite value chosen per test: None, Lax, Strict or no attribute. For each, a fresh browser context with no cookies visited a page on evil.test that posted Mallory's credentials to the login form. Then the browser navigated to /whoami on the application.
/whoami said mallory.no-cors fetch POST: the server logged a successful login every time. The browser stored the cookie only when it was SameSite=None. For Lax, Strict and no attribute, /whoami showed no user.SameSite decides which cookies are attached to a request. The forged login request carried no cookies and needed none. The cookie it produced arrived in the response to a top-level navigation, and Chromium stored it whatever its SameSite value. So the informational "login form without CSRF token" finding in the opening scenario was a real CSRF, and the Lax session cookie was not a reason to close it.
The OWASP cheat sheet says: "Login CSRF can be mitigated by creating pre-sessions (sessions before a user is authenticated) and including tokens in login form". It adds that the pre-session must be destroyed and a new session created at login, to avoid session fixation. A Sec-Fetch-Site or Origin check on the login handler is the other option. We did not build either into the lab's login endpoint.
The nuclei-templates commit we used has no template under dast/ that mentions CSRF. The template that bears on it is missing-cookie-samesite-strict, which is severity info. It sends one GET to the URL it is given and matches if the response headers contain a Set-Cookie and do not contain samesite=strict anywhere. We gave it five lab URLs.
SameSite=Lax: matched.SameSite=Strict: no match.SameSite=None and a theme cookie with SameSite=Strict in the same response: no match. The negative matcher looks at all headers at once, so one Strict cookie hides any other cookie.So on these five, it raised the Lax and unset cases, which may be deliberate choices, and was silent on the SameSite=None session cookie, the case that matters most for CSRF. It also does not distinguish an explicit Lax from a missing attribute, which behaved differently in Chromium. As its severity says, a cookie attribute is context, not a CSRF finding.
A scanner that tests CSRF by replaying a captured request with the token removed, or changed, is testing the token logic. That works for token defences, because the token is the only thing the server checks. We replayed against the lab with curl, with Alice's session cookie and no Origin or Sec-Fetch-* headers.
text/plain: 403. With application/json: 200.Origin and no Sec-Fetch-Site: 200. With Origin: https://evil.test:8443: 403. With Sec-Fetch-Site: cross-site: 403.The (k) line is the trap. A replay without browser headers was accepted by an endpoint that refused every cross-site request Chromium sent, because a request with neither header looks like the kind of non-browser client that cannot carry a victim's cookies anyway. "The request was accepted without a token" is evidence of CSRF only when the replay reproduces what a cross-site browser would send. Against a header-based defence, that means sending the Origin and Sec-Fetch-Site values a browser would set. The fall-through when both are absent is a separate question: it matters for any browser that sends neither header, and the OWASP cheat sheet calls the Origin fallback for browsers without Fetch Metadata "a mandatory requirement".
Two more limits of a scan. Testing (d) needs two authenticated sessions, so a scan with one test account cannot find it. And a scan with no session at all sees the login page and the public forms, which is where login CSRF lives and not much else.
The procedure below is general practice. It needs authorisation to test the target and should use test accounts you control. The proof of concept should change something harmless, on your own test account, and nothing else.
Set-Cookie header that creates the session, not the browser's cookie store, which in our lab reported a missing attribute as Lax. Note the SameSite value or its absence, the Domain attribute, and any __Host- prefix. If the action is authorised by a header the application's JavaScript adds and not by a cookie, CSRF does not apply to it.Origin or Sec-Fetch-Site, and a strict Content-Type.application/x-www-form-urlencoded, as multipart/form-data and as text/plain, and a JSON body as text/plain. Anything accepted can come from a form.Set-Cookie header, the proof-of-concept page, the server-side effect, the browser and version, and the time since login.All of this is general practice, except where it says it was measured.
Sec-Fetch-Site is cross-site, and decide deliberately whether to trust same-site, which includes every subdomain. Fall back to Origin when Fetch Metadata is absent. Our (k) stopped both cross-site and same-site browser requests.Lax or Strict. An explicit attribute removed the two-minute window in our lab. Treat it as defence in depth: it does nothing about GET state changes under Lax, sibling subdomains, or browsers that do not enforce it.Content-Type: application/json and keep CORS from approving arbitrary origins with credentials. Or require a custom header, which a cross-site page cannot send without a preflight.__Host- prefix, and prefer a signed, session-bound token to a naive double-submit.In source, CSRF is mostly the absence of a check, which is harder for a rule to see than the presence of a dangerous call. What static analysis can find well is the explicit opt-out: a CSRF middleware disabled in configuration, an exemption decorator or attribute on a route, a route that changes state on GET, or a JSON parser configured to accept every content type.
Each of those has a legitimate case, and a rule that flags them by name will be wrong in a predictable way. A webhook endpoint authenticated by an HMAC signature, or an API that only accepts a bearer header, is correctly exempt, because no browser attaches its credential. A flag on every exemption without reading how the route authenticates is the same mistake the SAST false-positive post describes for sink matching: the pattern matched, the condition that makes it dangerous was never checked. The opposite error is harder. A hand-written check like (c) or (d) can read as protection to a rule looking for a token comparison, and finding the flaw means following the logic. We did not run a static rule against the lab.
What source does not show:
Domain attributes if a proxy, gateway or platform rewrites cookiestext/plain?Set-Cookie say about SameSite, and was the proof taken inside the two minutes after login?Origin and Sec-Fetch-Site a browser would? And what happens when both are absent?Back to the four hypothetical findings.
/account/email. In the scenario, the medium was a false positive. A replay without the X-CSRF-Token header got 403, and a proof-of-concept form from a test domain got 403 as well. It was closed with both requests attached and a note naming the header as the defence, so the next scan's identical finding could be matched to the evidence.
/account/password. In the scenario, nothing was reported, and the endpoint was vulnerable. A replay with the token field removed changed the test account's password. The handler's check was rewritten to fail when the token is missing, and the team searched for the same pattern in other handlers.
/api/transfer. In the scenario, the "not applicable" note was wrong. A text/plain form with a JSON body moved a test amount between two test accounts. The endpoint was changed to require application/json, and the CORS policy was checked to make sure it did not approve arbitrary origins with credentials.
/login. In the scenario, the informational finding was real. A page on a test domain logged a fresh browser into the tester's second account, and the Lax session cookie made no difference. The login form now carries a pre-session token, and the session is replaced at login.
AppSecD's dynamic and API testing runs Nuclei, Dalfox, SQLMap, Commix, Katana, Arjun, FFuf and Interactsh for out-of-band detection, plus 150+ native checks and API discovery across 50+ web frameworks. Its static analysis includes dataflow taint analysis that traces source to sink across functions. Its findings are deduplicated across scans and move through new, reopened and fixed states, with maker-checker approval so a finding cannot be closed unilaterally.
That is the whole claim. data/products.ts is the single source of truth for what these products do. It names Nuclei, and it does not mention CSRF, SameSite, anti-forgery tokens or cookie attributes. So this post does not claim that AppSecD tests for CSRF. Nor does it claim anything about:
The measurements, the confirmation procedure, the fixes and the checklist above are general practice, not a description of how AppSecD works internally, and they apply to any scanner's output, ours included. The scenario in this post is hypothetical and does not describe any AppSecD deployment, user or finding.