This is an unconventional approach of CSRF that I came across while doing the pentest for an Android mobile application. The original request is as follows (NB: Values have been edited):
POST /edit/ HTTP/1.1
User-Agent: example Android (22/5.1.1; 320dpi; 720x1280;
Accept-Language: en-US
Cookie: cookies
Authorization: Bearer LPT:2:bearertoken
LP-U-DS-USER-ID: 69837
LP-U-RUR: VLL
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Host: edit.example.com
Connection: close
Content-Length: 484
sLPned_body=SLPNATURE.{"_csrftoken":"KpQCVh7TYsfcSFS0PHP1zsiV1hxkjk3B","username":"tester123","first_name":"tester123+tester","userid":"69837","device_id":"android-456b04ea5a32050d","biography":"#tester\n#testing","_uuid":"2da6821d-c609 t-900c-9f6e-51as443280f5","email":"[email protected]"}
When performing a CSRF an attacker can't predict the values for CSRF token, since it is validated in the request and it is rejected with an error 'token missing' even if the token was present in the request. At this point I started playing with the headers and came to know that instead of the token it is validating the user-agent. At the time of CSRF request the user agent is as shown below:
Mozilla/5.0 (Linux; Android 5.1.1; LS-5014 Build/LMY47V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/46.0.2490.76 Mobile Safari/537.36 example Android (22/5.1.1; 320dpi; 720x1280;
But if I change the User Agent as in the original request which is the user agent of the respective application,
Example Android (22/5.1.1; 320dpi; 720x1280;
The token will accept any value and the request is returned with 200 response.
Is there any way so that I can override the user agent while I am performing CSRF? I have never seen such a scenario anywhere else or read about it.