DedSec Security Research ·
Here is a hypothetical. A dynamic scan of several PHP applications returns four results about file upload. The first is "Unrestricted file upload", rated critical, on a profile-picture endpoint. The scanner posted a file named shell.php and got a 200 with {"ok": true}. The team escalates it as remote code execution. The second, on a document endpoint in a different application, is "Upload filter bypass via double extension": shell.php.jpg was accepted. The team confirms the server is Apache, knows that Ubuntu's PHP configuration only runs names that end in .php, .phtml or .phar, and closes it as a false positive. The third is "Stored XSS via SVG upload", rated medium. The team points out that every response carries X-Content-Type-Options: nosniff and closes it. The fourth is an old finding. After a real shell upload last quarter, the team added SetHandler none to the Apache <Directory> block for the uploads folder, reviewed the change and closed the finding.
As in the earlier posts in this series, each decision rests on the finding's title and on a belief about the server, not on what the scanner observed and what that observation can prove. We rebuilt each situation in a lab. The 200 in the first finding proved that the request was accepted and nothing else: in our version of that endpoint the file was stored outside the web root, and the only URL that returned it sent it as a download. The team's reasoning on the second matched Ubuntu's stock configuration exactly, and on the same Apache build with one older-style handler line, the same shell.php.jpg ran as PHP. The third was a true positive that nosniff did nothing to stop: Chromium ran the script inside an SVG served as image/svg+xml with nosniff set, and the script read the session cookie. And the fourth fix did not work. With SetHandler none in the <Directory> block, shell.php uploaded to that folder still executed, because the stock <FilesMatch> handler is applied after <Directory> blocks.
This post is for whoever is holding a file upload finding from a dynamic scan, or a clean result they are about to rely on. It covers:
.htaccess upload, and why it depends on one directiveIt is the twentieth 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, server-side template injection, CSRF, GraphQL and NoSQL injection. File upload borrows from three of them. Execution evidence is the same problem as in the command injection post, a file served to a browser is the stored form of the XSS post, and a filename with ../ in it is the path traversal post with a write instead of a read.
Sources, and how each was checked. We made the measurements below on our test machine on the morning of 12 November 2026, India time (between 01:25 and 01:38 UTC). It runs Ubuntu 24.04.4 on a virtual machine with two vCPUs of an AMD EPYC 9354P. Every server, script and 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:
cgi.fix_pathinfo was set to 1.http.server module, serving one uploads directory.nginx, Python and Chromium were already on the machine. Apache and PHP were not. We downloaded their Ubuntu packages once from the Ubuntu archive with apt-get download, on the host network, and unpacked them into the lab directory with dpkg -x. They were not installed, no system service was started, and their checksums are recorded in the lab. Nothing in the lab itself reached any other host.
The vulnerable handlers are deliberate lab constructs. The lab has one PHP upload handler with eight validation modes, each written to reproduce a pattern on purpose: no checks at all; trusting the Content-Type the client put on the file part; sniffing magic bytes with fileinfo; a case-sensitive blocklist of .php; a regex that accepts any name containing an image extension; an allowlist on the last extension; the same allowlist with a random server-side name; and a mode that builds the storage path from PHP's full_path field. Three more modes store differently: one decodes the image and re-encodes it as PNG, one returns 200 and keeps nothing, and one stores the file outside the web root under a random id. No real application should ship any of the first eight. Every request the handler received is logged with the filename PHP gave it, so each result below is matched to what the handler actually saw.
The server configurations are listed where they are used. We read Ubuntu's stock Apache PHP configuration, nginx's snippets/fastcgi-php.conf and PHP-FPM's default pool file from the packages, and the quotations from them below were checked against those files. We did not fetch Apache, nginx, PHP or browser documentation for this post. Where we describe what a server or browser does, it is what it did in the lab. We did not run any scanner, Nuclei template or upload-testing tool. The opening scenario is hypothetical. The numbers measure our lab, one build of each server and one browser, and none of them measures AppSecD or how any product tests file upload.
An upload finding is a claim about a chain, and each link is a separate fact with its own evidence.
A 200 on the upload proves the first fact. In the lab, two modes returned 200 for a PHP file and never served it from the upload directory. The discard mode answered {"ok": true} and wrote nothing, and a GET of /uploads/d1.php returned 404. The private mode wrote the file outside the web root under a random id. The file was not under /uploads/ (a test file stored this way returned 404 there), and the only route to it was a download script that sent Content-Type: application/octet-stream, Content-Disposition: attachment and nosniff. Chromium downloaded that response as download.bin and did not render it.
Neither is proof the endpoint is fine. In the second case the application still stored a stranger's bytes, which matters if anything later reads them: an admin preview, a thumbnailer, a virus scanner, a document converter. But neither is the critical finding the title described, and the evidence for that has to come from a later request.
Execution splits further. Code execution on the server is one finding. Script execution in a browser is another, and it needs a different kind of evidence: a page load, not a server response.
A multipart upload carries a filename in the part's Content-Disposition header, for example filename="shell.php". That name belongs to the client. What the server does with it is up to the application, and there are three possible outcomes:
r1.php.jpg as 92a4663bd7009158.jpg on A1 and 79e728eadc498ee1.jpg on A2. A scanner can only find that file if the upload response, or a later page, says where it went. The lab's handler returned the URL in its JSON. An application may instead reveal it only in a later page, such as a profile page that embeds the new avatar.PHP itself changes the name before the handler sees it. In PHP 8.3.6, $_FILES['f']['name'] for a part named ../t-none.php was t-none.php, and for ..\t-bs.php it was t-bs.php. PHP removed everything up to the last slash or backslash. The handler that saved under that name wrote into uploads/, and /t-none.php at the web root returned 404. PHP also keeps the original in a second field, full_path, which it filled with ../t-none.php. That field is covered in the traversal section below, because it undoes the stripping.
For a scanner the practical consequence is this. When the response does not say where the file went, the scanner has to guess the URL, and a wrong guess looks exactly like a file that was never stored. A clean upload result from a scan should say which of the three outcomes it observed. "Uploaded, then 404 at the guessed path" is not evidence that the file is unreachable.
The handler modes were run on the stock Ubuntu Apache configuration (A1 in the next section) unless stated otherwise, with the same 56-byte PHP file as the payload except in the two polyglot rows: <?php echo "UPL-" . (1336+1) . "-" . strrev("kram"); ?>. When it executes, it prints UPL-1337-mark. That string does not appear in the source, which contains 1336+1 and kram instead. So a fetched response that contains UPL-1337-mark proves execution, and one that contains 1336+1 proves the source was served as data.
| Mode | Filename sent | Upload | Fetched result |
|---|---|---|---|
| Client Content-Type | c1.php, part type image/png | 200 | executed |
| Client Content-Type | c2.php, part type application/x-php | 415 | - |
| Magic bytes (fileinfo) | m1.php, plain PHP | 415, sniffed text/x-php | - |
| Magic bytes (fileinfo) | m2.php, GIF89a then PHP | 200 | executed |
| Magic bytes (fileinfo) | m3.php, a real JPEG with PHP in a comment segment | 200 | executed |
Blocklist of .php | b1.php | 415 | - |
Blocklist of .php | b2.PhP | 200 | source, no Content-Type |
Blocklist of .php | b3.phtml, b4.phar | 200 | executed, both |
Blocklist of .php | .htaccess | 200 | 403 on fetch |
| Name contains an image extension | k1.jpg.php | 200 | executed |
| Name contains an image extension | k2.php.jpg | 200 | source, image/jpeg |
| Allowlist on last extension | l1.php.jpg, l5.php.JPG | 200 | source, image/jpeg |
| Allowlist on last extension | l2.jpg.php, l4.PHP, .htaccess | 415 | - |
| Allowlist on last extension | l3.php, NUL byte, .jpg | 415 | - |
Four things follow from that table.
The part's Content-Type is a claim the client makes. Our lab client wrote image/png on a PHP file and the check believed it. A check on that header is a check on what the client says the file is.
Magic bytes say what a file starts with, not what it is. fileinfo called the GIF polyglot image/gif and the JPEG polyglot image/jpeg. Both were stored under a .php name, and both ran: the GIF one returned 20 bytes, GIF89a, a newline and UPL-1337-mark. PHP prints anything outside <?php ... ?> as literal text and runs what is inside, so a valid image header in front of code is harmless to the interpreter. A magic-byte check only helps when the stored name is also forced to an extension the server will not execute.
Blocklists miss names the server treats as code. The case-sensitive blocklist stopped b1.php and let .phtml and .phar through, and on this server both of those executed. It also let .htaccess through. b2.PhP did not execute here, for a reason that belongs to the server, not to the blocklist.
The NUL byte did not get past anything. The filename l3.php, then a NUL, then .jpg arrived in $_FILES as l3.php. PHP 8.3.6 cut the name at the NUL before the handler saw it, so the extension check saw php and refused it. In the execution matrix below, the same trick under the no-check mode stored a file called shell.php. The classic bypass needed the check to see the whole string while a C-level filesystem call stopped at the NUL. In this build both sides see the same name. PHP 8.3.6 also refuses a NUL inside a path outright: file_put_contents() and fopen() both threw ValueError: ... must not contain any null bytes. Against this PHP version, then, a NUL-byte payload is of historical interest. We did not test other languages or older PHP versions.
The trailing-dot and trailing-space names in the execution matrix were stored exactly as sent, as shell.php. and shell.php (with a space). On Linux those are ordinary filenames. As general background, not tested here: Windows path handling strips trailing dots and spaces, which is where those tricks come from. We did not test Windows or IIS.
Whether a stored file runs is not a property of the file. It is decided by the web server's handler mapping, at the moment someone requests the URL. The same bytes under the same name can run on one server and be served as data on another.
We uploaded thirteen filenames, each containing the marker payload, through the no-check mode to twelve server profiles, and fetched each one back: 156 uploads, all accepted. The profiles were:
mods-available/php8.3.conf: <FilesMatch ".+\.ph(?:ar|p|tml)quot;> SetHandler application/x-httpd-php </FilesMatch>.AddHandler application/x-httpd-php .php instead.AllowOverride All on the uploads directory.SetHandler none inside <Directory .../uploads>.php_admin_flag engine off inside <Directory .../uploads>.<FilesMatch> with the stock pattern and SetHandler none, nested inside <Directory .../uploads>, plus nosniff and Content-Disposition: attachment headers on that directory.SetHandler none inside <Location /uploads/>.location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass ...; } to the default FPM pool, the block Ubuntu's default site ships commented out.location ~ \.php$ passed to the default FPM pool with no try_files and no path splitting (plus a matching location ~ \.php/ block).security.limit_extensions was deliberately set to .php .jpg.location /uploads/ { }.location ^~ /uploads/ that serves every file as application/octet-stream with nosniff and Content-Disposition: attachment."exec" means the response contained UPL-1337-mark. "src" means it contained the source.
| Filename | A1 | A2 | A3 | A4 | A5 | A6 | A7 | N1 | N2 | N3 | N4 | N5 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| shell.php | exec | exec | exec | exec | src | src | src | exec | exec | exec | exec | src |
| shell.phtml | exec | src | exec | exec | src | src | src | src | src | src | src | src |
| shell.phar | exec | src | exec | exec | src | src | src | src | src | src | src | src |
| shell.php5 | src | src | src | src | src | src | src | src | src | src | src | src |
| shell.PhP, shell.pHp | src | exec | src | src | src | src | src | src | src | src | src | src |
| shell.php.jpg | src | exec | src | src | src | src | src | src | src | src | src | src |
| shell.jpg.php | exec | exec | exec | exec | src | src | src | exec | exec | exec | exec | src |
| shell.php.xyz | src | exec | src | src | src | src | src | src | src | src | src | src |
| shell.php. (trailing dot) | src | exec | src | src | src | src | src | src | src | src | src | src |
| shell.php plus a trailing space | src | src | src | src | src | src | src | src | src | src | src | src |
| shell.php, NUL byte, .jpg (stored as shell.php) | exec | exec | exec | exec | src | src | src | exec | exec | exec | exec | src |
| shell.jpg | src | src | src | src | src | src | src | src | src | src | src | src |
35 of the 156 uploads executed. What decides each column:
Ubuntu's stock Apache block is anchored and case-sensitive. On A1, the regex ends in $, so .php.jpg, .php.xyz and the trailing dot did not match and were served as data. It has no case-insensitive flag, so .PhP did not match. But it does include .phar and .phtml, so a blocklist that only knows .php is not enough on a stock Ubuntu Apache. .php5 did not execute anywhere in the lab.
AddHandler works on every extension in the name. On A2, with the older AddHandler line, a .php anywhere among the name's extensions was enough. shell.php.jpg, shell.php.xyz and shell.php. all ran, and the match ignored case, so .PhP and .pHp ran too. Meanwhile .phtml and .phar were served as source, because that line only names .php. On this profile the allowlist-on-last-extension mode, which is a reasonable check, accepted l1.php.jpg and l5.php.JPG and both executed. The same two files were inert on A1. So the second finding in the opening scenario cannot be closed by reasoning about "Apache". It depends on which handler line that virtual host actually has.
SetHandler none in a <Directory> block did not stop the stock handler. A4 executed everything A1 did. The result is consistent with Apache applying <Files> and <FilesMatch> sections after <Directory> sections, so that the stock <FilesMatch> set the PHP handler again after the directory block had cleared it. We did not fetch Apache's documentation for this post, so that ordering is stated as what the lab showed. It is why the fourth finding in the opening scenario was still open. Three other placements did stop it. A5's php_admin_flag engine off turned the PHP engine off for the directory. A6 nested a <FilesMatch> inside the <Directory>. A7 used <Location>, which in the lab overrode the stock <FilesMatch>. None of the three executed anything.
nginx decides by location, and a prefix location does not protect a directory from a regex location. In N1 the regex \.php$ matched /uploads/shell.php and /uploads/shell.jpg.php and sent them to PHP-FPM. Nothing else ran, because the regex is anchored and case-sensitive (~, not ~*), and nginx served .phtml, .phar and .PhP as application/octet-stream. N4 added a plain location /uploads/ { }, and shell.php still executed: the regex location still won. N5 marked its prefix location ^~, and N5 executed nothing.
PHP-FPM's security.limit_extensions is what stopped the old nginx bug. The old nginx pattern passes /uploads/shell.jpg/x.php to PHP, because the URL ends in .php. That file does not exist, and with cgi.fix_pathinfo=1 PHP walks back along the path to shell.jpg and treats the rest as PATH_INFO. On N2, with the default pool, both /uploads/shell.jpg/x.php and /uploads/shell.jpg/.php got 403 Access denied.. The pool file's default, quoted from the package, is ;security.limit_extensions = .php .php3 .php4 .php5 .php7. On N3, whose pool allowed .jpg, both URLs returned UPL-1337-mark from a file named shell.jpg. Ubuntu's snippet in N1 has try_files $fastcgi_script_name =404;, and N1 returned 404 for both. So a finding that says "image executed as PHP via path info" on nginx is a claim about two settings at once, and only a fetch shows which one is wrong.
A file that does not execute is not served safely by default. Look at how the "src" cells were served. Apache sent no Content-Type at all for names it had no type for: .php5, .PhP, the trailing dot, the trailing space, and .php itself on A5 and A7, where the PHP handler no longer claimed it. nginx and Python's http.server sent application/octet-stream for unknown extensions. The difference matters, and the browser section shows why.
If Apache honours .htaccess files in the uploads directory, an attacker who can upload one can change the handler mapping for every file next to it. We uploaded two versions through the no-check mode, then uploaded the marker payload as a .jpg and fetched it:
AddHandler application/x-httpd-php .jpg<FilesMatch "\.jpgquot;> SetHandler application/x-httpd-php </FilesMatch>On A3, which had AllowOverride All on the uploads directory, both versions made the .jpg execute. On A1, A2, A5 and A7, which have AllowOverride None, neither did: the .jpg came back as source with image/jpeg. On all five profiles a GET of /uploads/.htaccess returned 403, because every Apache profile in the lab included a <FilesMatch "^\.ht"> Require all denied block. That is what a scanner sees: an accepted upload of a file it cannot fetch back. Whether the .htaccess took effect only shows up when a second, ordinary-looking file executes.
Two consequences for triage. A blocklist that does not include .htaccess is a finding on any Apache where AllowOverride permits handler directives in that directory. And confirming it takes two uploads and a fetch. The upload of .htaccess on its own proves nothing, because on four of these five profiles it was accepted and ignored. We did not test A5 with AllowOverride enabled.
Code execution needs an interpreter that is mapped to the file. An upload written to a bucket in an object store and served from there, or served by a server that has no PHP handler at all, is data. In the lab, Python's http.server served shell.php and shell.phtml as application/octet-stream, source and all, and nginx's N5 location did the same for every name. A scanner that reports remote code execution against a file it fetched from a static origin is reporting the wrong class.
The wrong class is not the same as no finding: what the browser does with the file, the next section, still applies. We did not test any object store. By the same mechanism, the Content-Type and Content-Disposition the store sends take the place of the web server's in everything below.
Stored XSS through an upload needs three things. The file holds script, a browser loads it as a document, and that document runs in an origin that is worth attacking. We tested the second part with Chromium 153.0.8010.12, using a small lab server that serves the same file with whatever response headers a query string asks for. The first column is the Content-Type the response sent.
| Served as | SVG with script | HTML with script |
|---|---|---|
| Its own type (image/svg+xml, text/html) | ran | ran |
| Its own type, plus nosniff | ran | ran |
| Its own type, plus Content-Disposition: inline | ran | ran |
| Its own type, plus Content-Disposition: attachment | downloaded | downloaded |
| text/html | ran | ran |
| application/xml or text/xml | ran | XML parse error |
| image/svg+xml | ran | XML parse error |
| text/plain, with or without nosniff | shown as text | shown as text |
| No Content-Type | shown as text | ran |
| No Content-Type, plus nosniff | shown as text | shown as text |
| application/octet-stream | downloaded | downloaded |
| image/png, with or without nosniff | image document, no script | image document, no script |
SVG loaded through <img src> | did not run | n/a |
In every "ran" cell, the script read document.cookie and got the session cookie set by the lab's application origin.
nosniff does not stop a response whose declared type is executable. It changes what a browser does when it would otherwise guess. With a correct image/svg+xml or text/html, the SVG and the HTML ran with nosniff and without it. That is the third finding in the opening scenario. The security headers post covers what nosniff does in general. In this lab the only case where it changed the result was an HTML file served with no Content-Type. Without nosniff, Chromium sniffed it as HTML and ran it. With nosniff it showed the file as text.
No Content-Type was the dangerous default. That is what Apache sent for many of the uploads it did not execute, including .PhP, .php5, the trailing dot and space, and .php on A5 and A7. We uploaded the HTML payload as nct.PhP on A1, and as nct.php on A5 and on A7. Apache served all three with no Content-Type, and Chromium sniffed each as HTML and ran its script with the application's cookie. A6 served the same file with nosniff and Content-Disposition: attachment, and Chromium downloaded it. So the A5 and A7 fixes stopped code execution on the server and left stored XSS in the browser. On this Apache, a fix for the uploads directory needs both halves.
Content-Disposition: attachment stopped rendering on navigation every time we sent it. Every response that carried it was downloaded: the SVG and the HTML with their own types, A6's response with no Content-Type, and the download script's application/octet-stream. An <img> does not run SVG script either, so an SVG that is only ever displayed through <img> is not the risk. The risk is the direct URL, which anyone can send someone.
The scanner's payload has to be valid XML. Our first SVG payload had a bare & inside its script. That is valid in HTML and invalid in XML, and Chromium showed an XML parse error page and ran nothing. With the script wrapped in <![CDATA[ ... ]]>, the same file ran. A scanner whose SVG payload is malformed will report an SVG endpoint clean when it is not.
A separate origin isolates cookies only if it is a separate host. The application set a host-only cookie on app.lab.test:8400. An SVG on app.lab.test:8401, a different origin by port, still read that cookie, because cookies do not separate by port. The same SVG on files.labusercontent.test:8400 ran with an empty document.cookie. Serving user content from a different registrable domain is the structural fix for script in uploads. A different port on the same host is not. We tested a host-only cookie. As general cookie behaviour, not tested here, a cookie set with a Domain attribute reaches every subdomain under that domain, which is why the separate host should be a separate registrable domain rather than a subdomain.
If the filename is used to build the storage path, ../ in it moves the write. PHP's name field stripped the path in the lab, as described above. But PHP 8.3.6 also exposed the unstripped value in full_path, a field PHP added for directory uploads (from general knowledge; we did not check the PHP changelog). The lab's full_path mode built the path from it:
../t-fp.php was stored at www/t-fp.php, one level above uploads/, and /t-fp.php returned UPL-1337-mark.<Location /uploads/> had stopped every upload from executing, the same request also executed at /t-fp.php. The write had left the directory the fix was protecting.The second line is the important one. Every per-directory defence in the execution section assumes the file lands in that directory. A traversal in the filename moves it somewhere the defence does not cover, so a traversal finding on an upload endpoint is worth more than its read-only cousin in the path traversal post. The evidence is the same kind: a marker file that appears at a path the application should never write to, fetched back. A scanner cannot see a write outside the web root at all, unless the file lands somewhere it can fetch.
A polyglot is a file that is valid as two formats at once. The lab's JPEG polyglot is a real 16 by 16 JPEG made with GD, with the PHP marker inserted as a comment segment straight after the start-of-image marker. The file utility called it JPEG image data, and fileinfo called it image/jpeg. Stored as .php on A1 it executed. That is the point of a polyglot: it passes a content check, and what happens next is again decided by the name and the server.
Re-encoding changes that. The lab's re-encode mode decodes the upload with GD and writes a new PNG under a random name. For the JPEG polyglot, the stored PNG contained neither 1336 nor php. The decoder reads pixels and ignores the comment, and in the lab the comment did not reach the output. The GIF polyglot, which is only a GIF header followed by PHP, was sniffed as image/gif and then refused with 415, because GD could not decode it. Re-encoding is a strong control because it rebuilds the file from what the format means rather than from what the file contains. It is not unconditional. Payloads built to survive a particular encoder's output, for example in compressed pixel data, are a known technique, and we did not test one. Combined with a server-chosen name and extension, it removed the execution path for the polyglot we tested, and it removes the SVG path because the output is never SVG.
An upload endpoint can also be a denial of service: a large file, many files, or an archive that expands to far more than it weighs if something unpacks it. These are real findings, but they are not confirmed the way the rest of this post is. The evidence is resource consumption on the target, and producing it means degrading the target. We did not test them, and they are out of scope here beyond saying that a scanner should not try to prove them against production.
UPL-1337-mark from 1336+1. The source coming back, even byte for byte, proves storage and serving, not execution. Fetching and finding the source is a negative result for execution.oob.php printed nothing and requested /cb/oobb-42 from a loopback listener. On A1 the fetch returned 0 bytes and the listener logged exactly that path. On A7, where the file was served as data, the fetch returned the source and the listener logged nothing. As in the out-of-band post, the callback proves something on the target ran your code. It does not prove which request triggered it unless the marker is unique per attempt.image/svg+xml, text/html or either XML type, the HTML ran as text/html or with no Content-Type and no nosniff, and attachment or octet-stream downloaded both.And the false positives:
text/plain, application/octet-stream, an image type or with attachment. Not code execution. Check the browser cases before closing.And one negative that is not a false positive: an SVG or HTML payload that did not run might simply be malformed, as ours was the first time.
The procedure below is general practice. It needs authorisation to test the target, should use files that do nothing harmful when they run, and should clean up after itself.
.php.jpg, .phtml, .phar or a case variant, fetch it and see what the server does with it. If .htaccess is accepted, upload a harmless one that maps a test extension, then a file with that extension, and fetch the second file.<img> if that is how the application displays it, to show the difference.../ in the filename and look for the file outside the upload directory. Remember that the framework may strip the name and keep the original elsewhere, as PHP's full_path does.All of this is general practice, except where it says it was measured.
.htaccess and traversal in one step. In the lab, the rename mode stored r1.php.jpg as a random .jpg that stayed inert even on the AddHandler profile..jpg.php, .PHP, .htaccess and the NUL-byte name, and accepted .php.jpg. That last one is safe only on a server whose handler mapping is anchored, which A1 was and A2 was not.SetHandler none in <Directory> lost to the stock <FilesMatch>. php_admin_flag engine off, a nested <FilesMatch> and <Location> all stopped execution. Keep AllowOverride None there. On nginx, use location ^~ /uploads/ so that no regex location can claim the files, and keep security.limit_extensions at its default.X-Content-Type-Options: nosniff, and Content-Disposition: attachment for anything that does not need to render inline. In the lab, Apache's default for unknown names was no Content-Type at all, and Chromium sniffed HTML from it.image/svg+xml, it ran script in every inline case we tried.Some of this is visible in source and configuration, and some is not. Static analysis can see a move or write whose destination is built from the client's filename or from full_path, an extension check against a blocklist, a check on the client's Content-Type, a check with no case folding, and the absence of a check altogether. Configuration scanning can see an AddHandler line for PHP, AllowOverride on a writable directory, an nginx PHP location without try_files or with ~*, and a changed security.limit_extensions. Those are real, checkable facts.
What a rule cannot easily see is the combination. The allowlist-on-last-extension mode is correct code that is safe on A1 and executes on A2. A rule that flags the handler will flag it on both. One that trusts it will miss A2. A rule that sees SetHandler none in the uploads directory would have to model Apache's section-merge order to know it does nothing on A4. That is the sanitiser-credited-against-the-wrong-sink problem from the SAST false-positive post, moved into configuration. We did not run a static rule or a configuration scanner against the lab.
What source and configuration do not show at all:
<FilesMatch> or AddHandler. For nginx, find the PHP location and the FPM pool's security.limit_extensions..htaccess accepted, and is AllowOverride open on that directory?../ in the name, and any API that exposes the unstripped path.<Directory> fix in the opening scenario looked right and did nothing.http.server. Not Apache with PHP-FPM through mod_proxy_fcgi, IIS, Tomcat, Node.js, Python or Ruby frameworks, or any CGI setup other than the PHP-FPM path-info case..php5 handler lines, .phps, .shtml with server-side includes, or other server-side template extensions. Not JSP, ASP or ASPX.AllowOverride enabled, or a .htaccess that sets php_flag engine on.Domain attribute, or SameSite behaviour of the uploaded document's requests.Back to the four findings.
Unrestricted upload of shell.php, 200 {"ok": true}. Accepted, not proven stored or served. In the lab's version of this endpoint the file sat outside the web root behind a download script that sent attachment, and Chromium downloaded a test file served that way. Downgraded from code execution, and kept open as "accepts arbitrary files", with a note to check what else reads them.
Double-extension bypass, closed as a false positive. Right for A1, where shell.php.jpg came back as source. Wrong for A2, the same Apache build with an AddHandler line, where it executed. Reopened until someone reads that virtual host's handler line and fetches the file. If it is AddHandler, the finding is critical and the fix is a server-chosen name.
Stored XSS via SVG, closed because of nosniff. True positive: served as image/svg+xml with nosniff, it ran and read the session cookie. Reopened, with attachment, a separate registrable domain or refusing SVG as the fix.
The <Directory> fix. Not fixed: on A4, .php, .phtml, .phar and .jpg.php all still executed. Reopened. Of the placements that worked in the lab, two still served HTML with no Content-Type, so the reopened finding includes the headers, and the retest has to upload a file and fetch it.
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. That line, and the shorter mentions of dynamic testing elsewhere in data/products.ts, are what the file says about it. None of them mentions file upload testing, so this post does not claim AppSecD tests for it. The measurements, the confirmation procedure, the fixes and the checklist above are general practice that applies to any scanner's output, ours included.
The scenario in this post is hypothetical and does not describe any deployment, user or finding.