Skip to content
Business logic Write-up Beginner

How I messed up my own profile data

The profile update endpoint enforced an OTP check only on PATCH requests, so switching the HTTP method to PUT let the author change their phone number without an OTP. The same PUT request also overwrote the whole user record, blanking fields that were not sent and breaking the profile page.

Himmat Singh Follow

Published on medium.com

Just wanted to share one of my experience which I had while testing one of the web application. I will be brief so that I do not waste anyone’s time :

Himmat Singh, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

This is an account of a bug found while testing a web application's profile feature. The application lets a signed-in user view and edit their own profile data: username, phone number, email address, first name and last name. The profile is updated through an API endpoint, /redacted/updateProfile, which the front end calls when the user submits the profile form. The report does not name the product or the program, and the endpoint path is redacted.

One part of the feature has its own flow: changing the phone number from the profile section requires the user to request an OTP first and then submit it. That extra step is the control the researcher set out to get around.

Setup

  • A normal user account on the application, with the username test_user.
  • A browser session logged into the site.
  • Burp Suite as an intercepting proxy, used to capture the profile update request, edit it and forward it.

No other roles, versions or preconditions are described.

Finding it

The starting point was the ordinary profile edit. The researcher changed the username field to test_user, submitted the form, and intercepted the resulting request in Burp Suite. Forwarding it produced the following request and response.

Request:

HTTP
PATCH /redacted/updateProfile

……

……

{'user':'test_user'}

Response:

HTTP
HTTP/1.1 200 OK

{'user':'test_user','number':'9999999999','email':'[redacted]','first':'test','last':'user'….}

The request body is a JSON-like object naming the field to change, and the response returns the profile record, including the phone number, email and name fields. The endpoint is a PATCH, and the body carries only the parameter the user edited.

From the original on medium.com

Exploitation

Step 1: try to change the phone number directly

Because the normal phone-number change requires an OTP, the researcher tried to set the number directly through the same /updateProfile API, without going through the OTP flow.

Request:

HTTP
PATCH /redacted/updateProfile

……

……

{'user':'test_user','number':'1234567890'}

Response:

HTTP
HTTP/1.1 401 Unauthorized

…..

{'error','**Updating Phone-number requires an OTP paramater**'}

The server rejected the request with 401 Unauthorized and an error saying that updating the phone number requires an OTP parameter. So the OTP check is enforced on this endpoint, and the researcher did not have an OTP to supply.

Step 2: change the HTTP method from PATCH to PUT

Knowing that PUT is also used to update records, the researcher changed the method on the same request from PATCH to PUT and forwarded it from Burp Suite.

Request:

HTTP
PUT /redacted/updateProfile

……

……

{'user':'test_user','number':'1234567890'}

Response:

HTTP
HTTP/1.1 200 OK

{'username':'test_user','number':'1234567890','email':'[redacted]','first':'test','last':'user'….}

This time the server returned 200 OK and the response shows the phone number changed to 1234567890. The OTP requirement that blocked the PATCH request did not apply to the PUT request.

Step 3: observe the side effect

The success did not last. After logging out and logging back in with the same username, the whole profile page was broken: the name and other profile information were not visible, and every field showed UNDEFINED.

The researcher's explanation is that the two methods are handled differently by the server. With PATCH, the server updates only the specific data or parameters present in the body, so a body of:

Text
{'username':'test_user'}

would only update username. With PUT, the server mostly uses the request to replace the whole record, so a body of:

Text
{'username':'test_user','number':'1234567890'}

replaces the entire user record, putting NULL into every parameter that was not sent, such as first, last and email. That is what produced UNDEFINED across the profile. The researcher notes that this behaviour depends on the API configuration, but that it mostly happens this way.

Root cause

The OTP check blocked the PATCH request but not the PUT request to the same endpoint, so switching the method bypassed the restriction. The PUT request to the same endpoint did not require the OTP parameter, so switching the method bypassed the restriction. This is a broken authorisation issue: the same sensitive field can be written through a route that lacks the control.

Separately, the researcher explains that PUT is mostly used to replace the whole record rather than a partial update, depending on API configuration. The researcher's explanation is that fields omitted from the body were set to NULL, which is why the rest of the profile showed UNDEFINED. The report does not describe the server-side implementation, so the exact reason the OTP check is missing on PUT is not stated.

Impact

Within the researcher's own account, the impact was a bypass of the OTP requirement for changing the phone number, plus corruption of the rest of the profile record because PUT replaced the whole record. The report does not demonstrate the attack against another user's account, so whether the same method switch works cross-account is not shown. The report also does not state whether the OTP flow is the only barrier protecting the phone number, or what an attacker could do with a changed number beyond the change itself.

Fix

Based on the finding, the OTP requirement should be enforced for every method that can update the phone number on /updateProfile, not only for PATCH, and the PUT handler should either be removed or made to apply the same validation as PATCH. If PUT is kept, it should not silently null out fields that are absent from the body unless a full replacement is genuinely intended and authorised.

Variants to test

  1. Method switching on other restricted fields. Take any field that has an extra check (OTP, password confirmation, admin approval) and replay the same body with PUT, POST, PATCH and other methods the endpoint accepts. A positive result is a 200 where the original method returned 401 or an error about the missing check.
  2. Partial versus full update semantics. Send a body containing only one field with PUT and then read the record back. A positive result is other fields becoming NULL, empty or UNDEFINED, which shows the handler replaces the whole record.
  3. Method override headers and parameters. Where the front end or proxy supports them, try overriding the method through headers or query parameters on a request that is otherwise blocked. A positive result is the restricted operation succeeding while the visible method stays the same.
  4. Other endpoints sharing the same handler pattern. Look for other update endpoints in the same application and repeat the method switch. A positive result is the same bypass on a different resource, which suggests a shared design flaw rather than a one-off.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 13 min read.

What happened, in plain words

A security researcher was testing a website that lets people create an account and keep a profile: a username, a phone number, an email address, a first name and a last name. The site has a rule that changing your phone number requires sending an OTP first and then submitting it.

The researcher found that the rule could be skipped. The website's profile form sends its changes to a small piece of software on the server called an API. When the form asked to change the phone number in the normal way, the server refused and demanded the code. But when the researcher changed one word in the request, the name of the HTTP method, from PATCH to PUT, the server accepted the change without any code at all.

There was a second surprise. The change worked, but afterwards the researcher's own profile page was broken: every field showed UNDEFINED. The researcher's explanation is that PATCH updates only the fields listed, while PUT is mostly used to replace the whole record, depending on API configuration. The researcher's explanation is that only a username and a phone number were sent, so the other fields were set to NULL.

So this is a story about two lessons: a security check that only guarded one door into the same room, and a method that quietly wipes data you did not mention.

The pieces you need to know first

Before walking through the steps, here are the ideas the report relies on, explained from scratch.

  • A web application is a program you use through your browser. You type into forms, click buttons, and the browser sends messages to a server (a computer somewhere else) that stores and processes the data.
  • A profile is the set of personal details attached to your account. Here it holds a username, a phone number, an email address, a first name and a last name.
  • An API (Application Programming Interface) is the set of addresses and rules a website's own pages use to talk to its server. Think of it as the serving hatch between the dining room (your browser) and the kitchen (the server): your browser does not cook, it passes an order through the hatch and gets a dish back. The report's API address is /redacted/updateProfile, which is the hatch used whenever a profile is saved. The word redacted means the real name was removed before publishing.
  • An HTTP request is the message your browser sends to the server. It has a few parts: a method (a verb saying what kind of action you want), a path (which address you are talking to), sometimes headers (extra labels and information), and sometimes a body (the actual data, such as the new username).
  • HTTP methods are the verbs. The ones in this story are:
    • GET, used to read something.
    • PATCH, used to change only the parts of a record that you list.
    • PUT, used to replace a whole record with what you send.
    • POST, used to create something or submit data. A useful everyday comparison: PATCH is like telling a colleague "change the phone number on my contact card and leave everything else alone". PUT is like handing them a brand new contact card and saying "this is now my card", so anything you left off the new card is simply gone.
  • A response is the server's reply. It starts with a status code, a three-digit number summarising what happened. 200 OK means it worked. 401 Unauthorized means the server refused because something required was missing or wrong.
  • JSON is a common way of writing data as text so both sides can read it. It looks like {'user':'test_user'}, a name in quotes, a colon, and a value in quotes. The report's examples use single quotes, which is not strict JSON, but the idea is the same: labelled fields with values.
  • An OTP (one-time password) is a short code sent to your phone or email that you must type in to prove the action is really you. It expires after one use, which is why it is called one-time.
  • Burp Suite is a tool used by security testers. It sits between your browser and the server like a postbox you can open: it catches each request before it is delivered, lets you read and edit it, and then forwards it. That is how the researcher could change PATCH to PUT by hand.
  • An intercepting proxy is the general name for that kind of middleman. Your browser is configured to send its traffic through it, so nothing reaches the server without passing through the tool first.
  • Broken authorisation is the name of the weakness here. Authorisation means deciding whether a particular person is allowed to do a particular thing. It is broken when the check exists on one route but not on another route that does the same thing, so the rule can be sidestepped.
  • NULL is a special value meaning "nothing at all", as opposed to an empty text or the number zero. When a database field is set to NULL, the website has no value to display, which is why the page showed UNDEFINED.

The setup

The researcher used:

  1. A normal account on the application, with the username test_user.
  2. A browser logged into the site.
  3. Burp Suite, set up as an intercepting proxy, to capture the profile update request, edit it, and forward it.

No special role, software version or other precondition is described.

Finding it

The starting point was the most ordinary action possible: editing your own profile. The researcher went to the profile page, changed the username field to test_user, and pressed submit. Burp Suite caught the request on its way out. Forwarding it produced this request and this response.

Request:

HTTP
PATCH /redacted/updateProfile

……

……

{'user':'test_user'}

Line by line:

  • PATCH /redacted/updateProfile is the first line of the request. PATCH is the method, meaning "change only what I list". /redacted/updateProfile is the address on the server, the serving hatch for profile updates.
  • The …… lines stand for parts of the request the report left out, such as headers and other details. They are not data the researcher typed.
  • {'user':'test_user'} is the body: one field named user, with the value test_user. This is the only thing the form asked to change.

Response:

HTTP
HTTP/1.1 200 OK

{'user':'test_user','number':'9999999999','email':'[redacted]','first':'test','last':'user'….}

Line by line:

  • HTTP/1.1 200 OK is the status line. HTTP/1.1 is the version of the protocol, and 200 OK means the server accepted the request and did what was asked.
  • The body is the profile record the server sent back: the username, the phone number 9999999999, the email [redacted], the first name test and the last name user. The …. at the end shows the record continues with more fields that were not printed.

This step matters because it shows two things. First, the endpoint accepts a PATCH and returns the whole profile, so the researcher can see exactly which fields exist. Second, the body only carries the field the user edited, which is the normal, safe way to make a small change.

From the original on medium.com

Exploitation

Step 1: try to change the phone number directly

The normal way to change a phone number on this site is to go to the profile section, request an OTP, receive it, and submit it along with the new number. That extra step is the control the researcher wanted to get around. The idea was simple: if the profile form can save a username through /updateProfile, maybe the same endpoint will save a phone number too, if the number is simply included in the body. If it does, the OTP step has been skipped.

Request:

HTTP
PATCH /redacted/updateProfile

……

……

{'user':'test_user','number':'1234567890'}

Line by line:

  • The method is still PATCH, the same as the normal profile save.
  • The body now has two fields: user set to test_user, and number set to 1234567890. The researcher added the phone number by hand, hoping the server would accept it without the OTP.

Response:

HTTP
HTTP/1.1 401 Unauthorized

…..

{'error','**Updating Phone-number requires an OTP paramater**'}

Line by line:

  • 401 Unauthorized means the server refused. Something the request needed was missing.
  • The body explains why: an error saying that updating the phone number requires an OTP parameter. In other words, the server knows this endpoint can change the phone number, and it insists on the code before it will do so.

So the OTP check is real and it is enforced on this endpoint. The researcher did not have an OTP, so this route was closed. The word paramater is a typo in the server's own message, kept here as it appeared.

Step 2: change the HTTP method from PATCH to PUT

The researcher knew that PUT is also used to update records. The researcher knew that PUT is also used to update records, so changed the method on the same request from PATCH to PUT. So the researcher changed the method on the same request from PATCH to PUT and forwarded it from Burp Suite.

Request:

HTTP
PUT /redacted/updateProfile

……

……

{'user':'test_user','number':'1234567890'}

Line by line:

  • The only change from the previous request is the first word: PUT instead of PATCH. The address and the body are identical.
  • The body still asks for user to be test_user and number to be 1234567890.

Response:

HTTP
HTTP/1.1 200 OK

{'username':'test_user','number':'1234567890','email':'[redacted]','first':'test','last':'user'….}

Line by line:

  • 200 OK means the server accepted the request this time.
  • The returned record shows number is now 1234567890, the value the researcher sent. The phone number was changed without any OTP.
  • The other fields are still listed in the response, which makes it look as though everything is fine.

This is the core of the finding. The OTP requirement that blocked the PATCH request did not apply to the PUT request, even though both requests went to the same address and asked for the same change. The OTP requirement that blocked the PATCH request did not apply to the PUT request.

Step 3: observe the side effect

The success did not last. After logging out and logging back in with the same username, the whole profile page was broken. The name and other profile information were not visible, and every field showed UNDEFINED.

The researcher's explanation is that the two methods are handled differently by the server:

  • With PATCH, the server updates only the specific data or parameters present in the body. A body of:
Text
{'username':'test_user'}

would only update username, and everything else would stay as it was.

  • With PUT, the server mostly uses the request to replace the whole record. A body of:
Text
{'username':'test_user','number':'1234567890'}

replaces the entire user record, putting NULL into every parameter that was not sent, such as first, last and email. That is what produced UNDEFINED across the profile: the page had no value to show for those fields.

The researcher notes that this behaviour depends on the API configuration, but that it mostly happens this way. The everyday comparison again: PATCH is editing one line on a form, PUT is handing in a fresh form where every blank box is treated as deliberately left empty.

Root cause

The OTP check blocked the PATCH request but not the PUT request to the same endpoint. A handler is the piece of server code that runs when a particular method and address are requested. The PUT request to the same endpoint did not require the OTP parameter, so switching the method bypassed the restriction. This is a broken authorisation issue: the same sensitive field can be written through a route that lacks the control.

Separately, the researcher explains that PUT is mostly used to replace the whole record rather than a partial update, depending on API configuration. The researcher's explanation is that fields omitted from the body were set to NULL, which is why the rest of the profile showed UNDEFINED. The report does not describe the server-side implementation, so the exact reason the OTP check is missing on PUT is not stated.

Impact

Within the researcher's own account, the impact was a bypass of the OTP requirement for changing the phone number, plus corruption of the rest of the profile record because PUT replaced the whole record. The report does not demonstrate the attack against another user's account, so whether the same method switch works cross-account is not shown. The report also does not state whether the OTP flow is the only barrier protecting the phone number, or what an attacker could do with a changed number beyond the change itself.

Fix

The report does not say what was changed. Based on the finding, the OTP requirement should be enforced for every method that can update the phone number on /updateProfile, not only for PATCH, and the PUT handler should either be removed or made to apply the same validation as PATCH. If PUT is kept, it should not silently null out fields that are absent from the body unless a full replacement is genuinely intended and authorised.

Variants to test

  1. Method switching on other restricted fields. Take any field that has an extra check (OTP, password confirmation, admin approval) and replay the same body with PUT, POST, PATCH and other methods the endpoint accepts. A positive result is a 200 where the original method returned 401 or an error about the missing check.
  2. Partial versus full update semantics. Send a body containing only one field with PUT and then read the record back. A positive result is other fields becoming NULL, empty or UNDEFINED, which shows the handler replaces the whole record.
  3. Method override headers and parameters. Where the front end or proxy supports them, try overriding the method through headers or query parameters on a request that is otherwise blocked. A positive result is the restricted operation succeeding while the visible method stays the same.
  4. Other endpoints sharing the same handler pattern. Look for other update endpoints in the same application and repeat the method switch. A positive result is the same bypass on a different resource, which suggests a shared design flaw rather than a one-off.

Glossary

  • API: the set of addresses and rules a website's own pages use to talk to its server, like a serving hatch between browser and server.
  • Authorisation: the decision about whether a particular person is allowed to perform a particular action.
  • Broken authorisation: a weakness where that decision is missing or can be sidestepped on some route, even though it is enforced elsewhere.
  • Burp Suite: a tool that sits between browser and server, catching each request so the tester can read, edit and forward it.
  • Endpoint: a specific address on a server that accepts requests, such as /redacted/updateProfile.
  • Handler: the piece of server code that runs when a particular method and address are requested.
  • Header: extra labelled information attached to a request or response, separate from the body.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • HTTP method: the verb at the start of a request (GET, PATCH, PUT, POST) saying what kind of action is wanted.
  • Intercepting proxy: a middleman tool that catches traffic between browser and server so it can be inspected and changed.
  • JSON: a common text format for writing data as labelled fields and values.
  • NULL: a special value meaning "nothing at all", distinct from empty text or zero.
  • OTP (one-time password): a short code sent to your phone or email that proves the action is really you and expires after one use.
  • PATCH: an HTTP method meaning "change only the fields I list".
  • PUT: an HTTP method meaning "replace the whole record with what I send".
  • Request: the message a browser sends to a server, made of a method, a path, optional headers and an optional body.
  • Request body: the data part of a request, such as the fields being saved.
  • Response: the server's reply, starting with a status code and usually carrying a body.
  • Status code: a three-digit number at the start of a response summarising the outcome, such as 200 OK or 401 Unauthorized.
  • 200 OK: the status code meaning the request succeeded.
  • 401 Unauthorized: the status code meaning the server refused because something required was missing or wrong.
  • Web application: a program you use through your browser, whose data is stored and processed on a server.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.