Monday 14 September 2020

Thankyou! No content-type

Hi Everyone,

I was testing an application a few days back. It was an investing application and most of the application was secure.

Suppose the application is target.com. So the application had a feature where we could upload a document.

I tested for normal file upload vulnerabilities, though the application was giving me an error if I tried to upload any document other than valid file types.

The application had a check on content-type, filename and also on its content.

When you uploaded any document, the response contained a URL to which the file could be downloaded.

Consider that when you upload a file the response will contain something like this:

200 OK

{{URL: https://target.com/file/1234}}

As it was already checking that html should not be uploaded I didn't test for XSS. 

After testing the feature, I started to check other feature of the application. I saw few of my documents there, which I downloaded. 

In the response I saw a thing interesting. The response did not had "Content-type" header.

So the browser would just check the file content and display it accordingly. To those who don't know,
If no content-type is set in the response, the browser checks the file content and see if the content is html it will render as HTML. If it is javascript, it will render as javascript.

So I went to the upload document feature to check for XSS. I already knew that I don't need to change the filename or Content-type as the application doesn't check that when it is providing the document to the user. 

The Only thing that I needed to change was executing my payload in the request body.

So I started uploading the document with a valid filename test.jpg, without changing its content-type in the request and sending my payload in the content of the file.

It turned out that server was also checking the content of the file and would give me an error when I sent a payload. So there was waf which would check for this. 

After checking for few payloads I found that script tag is checked by the application, though it was not checking for html tags if it was sent like <HtmL>. After that I also found that img tag is not being checked by WAF.

I send a payload like

<HTml><img src=x onerror="alert(2)"></HTml> 

And, it didn't work. Later I found out that the application was also checking for alert. I tried prompt,confirm and different ways in which alert could be sent like a;alert(2) though that also didn't worked. 

So to send this issue to the bug bounty company I need to execute the payload so that they will accept it. After checking on google I found something like this, console.log can also be utilized to show the impact.

So I sent the payload.


It worked. 



So I successfully bypassed the waf that wasn't the trick here. The trick was the checking the file which was uploaded had no content type.

Reported it to the company. 






Monday 31 August 2020

Attacking templates in a web creating application

Hi Everyone,

Few days back I was testing an application which allows users to create a web for them. I tested it for few days and found some critical vulnerabilities in it.

So consider this web application as target.com.

This application allows to create a web and we can install the templates that are available in the applications template store. There was also an option to create our own template.

So I started creating my own templates. These templates wont show up in the store as these are private templates and not Public. There was no option available to the user to create a Public template for security reason.

When I was creating a template I saw an api with a parameter "isPublic" which was set to false.

Ok, This looks interesting. 

I didn't have any idea at that moment why is that parameter being sent and that I cannot create a Public template.

I changed false to true and resumed my testing. After few moments I went to the template store just to check which templates are available and was excited to see my template there.


There I knew this was something critical.

My theme would be shown to every user who creates an account with target.com. 

I created a PoC with a template name "Target.com is not secure" to show the impact of the issue. This would mean that business of that application would be at risk.

The issue got fixed in a few hours.