How to complete the HTTP Method Override Challenges
All of the method override challenges use the same mechanism so we can cover them all in this solution.
Sometimes tools and libraries will not issue TRACE or PATCH requests. There is a specific HTTP header we can use to try and have POST requests treated as other verbs.
The header "X-HTTP-Method-Override" is not guaranteed to work on every server, but some HTTP servers will take this header and treat the request using the value in the header:
X-HTTP-Method-Override: DELETE
This is worth understanding because it might also be used to bypass validation, or trigger functionality that the user is not authorized to trigger.
POST /heartbeat
Issue a
POSTrequest to/heartbeatwith anX-HTTP-Method-Overrideheader specifying the verb you actually want
POSTrequest can be sent by all tools- We need to add the header
X-HTTP-Method-Overrideto the request and the value should be the verb we want to send e.g.TRACE
Basic Instructions
Each challenge requires a different verb, but the process is the same for each, the only difference is the value of the X-HTTP-Method-Override header
- Issue a POST request to end point "/heartbeat"
- The request should have an
X-HTTP-Method-Overridewith the value associated with the challenge i.e.DELETE,PATCH,TRACE - The request should have an
X-CHALLENGERheader to track challenge completion - The response status code should match the value for teh challenge overridden verb
- for
DELETEbe405 - for
TRACEbe501 - for
PATCHbe500as the API is simulating a server error
- for
NOTE: This header feature is normally implemented by the HTTP server so often development teams are not even aware that this is possible. Depending on how requests are validated in code it might be possible for someone, who has amend access using POST but who does not have DELETE access, to be able to use this header approach to delete something.
NOTE: As an additional exercise, you might want to see if you can DELETE todos using a POST and the X-HTTP-Method-Override header. Experiment and see what you can achieve using this approach.
Example Request
> POST /todos/3 HTTP/1.1
> Host: apichallenges.herokuapp.com
> User-Agent: rest-client
> X-HTTP-Method-Override: DELETE
> X-CHALLENGER: x-challenger-guid
> Content-Type: application/json
> Accept: */*
> Content-Length: 108