Day 5 of 860 minCipher CadetHands-on lab

Day 5: Parameter Manipulation and Role Tampering

Taught by Mr Elite Updated

By the end of today you can

  • Change a single parameter in a request using Burp Repeater and compare it with a baseline
  • Tell from the response whether the server accepted, rejected or ignored the change
  • Recognise an ID that the server trusts without checking who you are
  • Record accepted and rejected changes in a short, clear note

Warm-up

Answer from memory first, then tap to check. Recalling yesterday is what makes it stick.

Why does Burp test something the page in your browser cannot?

The page can only enforce rules in your browser. Burp lets you send what you like, so you see what the server really accepts.

When you edit a prompt inside a JSON body, what must you do with inner double quotes and line breaks?

Put a backslash before inner double quotes and write line breaks as \n so the JSON stays valid.

Yesterday you changed the words in a prompt. A chat request carries more than words, though. It also holds a model name, a temperature, a user ID and a role for each message. Each one is a small instruction to the server, and the page only ever sends the values its developer chose.

Today you learn to ask a plain question of each value: if I change this, does the server believe me? A server that trusts a role field or an ID it should have checked is a real finding. You will practise on a tiny server on your own machine, then on the SecurityElites lab.

Parameters beyond the prompt

A parameter is a named value sent with a request. In a chat API body you will usually see fields like these next to the messages. Some are harmless settings. Others decide who you are or what you may do.

role
Who a message comes from, such as user, assistant or system. System messages carry the developer's rules.
temperature
A setting for how random the model's answers are. It normally has a limited range.
ID value
A number or string naming an object, such as a user, a conversation or a share link.
server-side check
A rule the server applies itself, so changing the page or request cannot skip it.

The key idea is trust. The server should treat everything in a request as untrusted input, because you control it. If it uses a value without checking it, we call that trusting the client. Our job is to find out which values it trusts.

The method: one change, one comparison

You met this rule yesterday and it matters even more now. Send the untouched request first and keep the response as your baseline. Then change exactly one value and send again. If you change three things and the server errors, you cannot tell which one caused it.

For each change, note three things: the status code (200 means accepted, 400 or 403 usually means refused), the body, and whether the response reflects your value back. A server that accepts and uses your value has trusted you. One that accepts but quietly ignores it has not.

Quick check

You change the role and the temperature in one request, and the server returns an error. What is the problem with that test?

Watch me do it: a toy server on your own machine

To see trust and rejection clearly, I want you to run a small fake chat API. It runs only on your computer at 127.0.0.1, which nobody else can reach. It checks the role and the temperature, and it deliberately trusts the user_id. That last part is the flaw we will find.

bash
python3 --version
Confirms Python 3 is available. Expect a version number.
python
import json
from http.server import BaseHTTPRequestHandler, HTTPServer

class H(BaseHTTPRequestHandler):
    def do_POST(self):
        n = int(self.headers.get('Content-Length', 0))
        try:
            d = json.loads(self.rfile.read(n))
            role = d['messages'][0]['role']
            temp = d.get('temperature', 0.7)
            if role != 'user':
                out, code = {'error': 'role not allowed: ' + role}, 403
            elif not 0 <= temp <= 1:
                out, code = {'error': 'temperature must be 0 to 1'}, 400
            else:
                out, code = {'reply': 'echo', 'temperature_used': temp, 'profile': 'data for user ' + str(d.get('user_id'))}, 200
        except Exception as e:
            out, code = {'error': 'bad request: ' + repr(e)}, 400
        body = json.dumps(out).encode()
        self.send_response(code)
        self.send_header('Content-Type', 'application/json')
        self.send_header('Content-Length', str(len(body)))
        self.end_headers()
        self.wfile.write(body)

HTTPServer(('127.0.0.1', 8000), H).serve_forever()
A deliberately flawed toy API. It validates role and temperature but never checks that user_id belongs to you.
http
POST /chat HTTP/1.1
Host: 127.0.0.1:8000
Content-Type: application/json

{"model":"demo-1","user_id":1001,"temperature":0.7,"messages":[{"role":"user","content":"hello"}]}
The baseline request. Burp Repeater updates Content-Length for you when you edit the body.

Here is what you should see. Role system returns 403 with 'role not allowed: system', so the server checks roles. Temperature 5 returns 400 with a range message, so it checks that too. Temperature 0.2 returns 200 and temperature_used shows 0.2, which is fine because it is a valid value. User_id 1002 returns 200 with 'data for user 1002'. The server never asked whether you are user 1002, so it trusted your ID. That is the finding.

Quick check

In the toy server, user_id 1002 returned 200 with data for that user. What does this show?

Your turn: the SecurityElites share-link lab

Now you apply the same questions to a lab built for it. Use only the SecurityElites lab, never a real chat service. The lab description says conversations can be fetched by ID and the IDs are not random. Your job is to find out how far that trust goes.

Your turn

AI Chat Share-Link IDOR

ChatNova lets you share a conversation by link, and the share page serves conversations by ID. This is the toy server's user_id flaw in a realistic setting. We use it now because it practises changing one ID and judging the response.

Open the lab in a new tab

What to try

What to notice

  • Whether the response says anything about who owns the conversation
  • How the ID is built, and whether a pattern makes the next value easy to guess
  • The difference in the server's answer for an ID that exists and one that does not

If it did not work

Changing several fields at once

Reset to the baseline and change a single value per request. Then you know what caused each result.

Assuming status 200 means the server trusted you

Read the body. A 200 that ignores your value is different from one that uses it. Look for your value reflected back.

Breaking the JSON and reading the error as a security result

A parse error comes from your typo. Fix the quotes and commas, then resend.

Testing outside the lab or your own machine

Stay on 127.0.0.1 or the SecurityElites lab. Never change IDs on a real service that is not yours.

Recap

  • A request holds many parameters beyond the prompt, and each is untrusted input.
  • Change one value at a time and compare with a baseline.
  • A 403 or 400 with a clear message shows a server-side check exists.
  • A server that uses your user ID or object ID without checking ownership has trusted the client.
  • Error messages are clues, so read them fully and record them.
  • Only test your own setup or the named lab.

Cheat sheet

Baseline
The unchanged request and response you compare against
403 / 400
Usually a refusal or a validation failure
200 with your value reflected
The server accepted and used your change
IDOR
Insecure direct object reference: an ID is used without an ownership check
Ctrl+R
Sends a captured request to Repeater in Burp
Ctrl+C in terminal
Stops the toy server

Before the next day

Mission: One Change Per Request

Practise the one-change method and record what the server accepted or rejected. This note becomes evidence for the finding you will write on Day 7, so be precise.

About 35 min

You are done when: A text file named day5-changes.txt holding a table of at least eight changes with results, plus a short note on accepted and rejected values.

Want more? Change the toy server so it checks user_id against a fixed value of 1001, rerun your tests, and note how the 1002 response differs.

Quiz

4 questions. Your score is saved with your progress.

1. Why is a baseline request useful?

2. The server answers 403 'role not allowed: system' when you set role to system. What does this tell you?

3. You change an ID from 1001 to 1002 and get another person's data back. What is the best description?

4. Why change only one parameter per request?

Finish the day

Mark the day complete to save your progress.

Next: Day 6 turns to information disclosure: finding leaked system prompts, internal fields and verbose errors in responses. The error messages you read today are the first clues. Coming soon.

Tell someone you are doing this:WhatsAppXLinkedIn

Your notes

Private to this device. Write what you want to remember from today.