# Pentest your own app

> Tamper with requests at a breakpoint or with Rewrite rules, replay and race them, check headers and leaked secrets, on systems you own or may test.

Source: https://docs.subcloak.com/cloak-proxy/guides/pentest-your-own-app/

This guide uses Cloak Proxy to probe your own app's API for common weaknesses: tampering with a request mid-flight, replaying it with changed parameters, sending it many times at once to find race conditions and missing rate limits, checking the response security headers and for leaked secrets, and rewriting or scripting systematic edits across many requests. It finishes with how to record findings.

> **Danger:**
> Test only systems you own or have **written permission** to test. Intercepting, decrypting or tampering with traffic you are not authorized to touch is illegal in most places. Everything below assumes the app and its backend are yours or covered by a signed authorization.

## What you need

| | |
|---|---|
| Written authorization for the target, if it isn't yours | Keep it on file before you start |
| Cloak Proxy capturing the app, with HTTPS decrypted | See [Debug a mobile app](https://docs.subcloak.com/cloak-proxy/guides/debug-a-mobile-app/) or [macOS traffic](https://docs.subcloak.com/cloak-proxy/capture/macos-traffic/) |
| A test account you can safely change data with | Tampering can create, modify or delete real records |

## Intercept and tamper at a breakpoint

A breakpoint holds a request while the app waits, so you can change exactly what reaches the server.

1. Capture the request you want to probe, right-click it, and choose **Tools → Breakpoint…**. Leave **Pause on request** on. Keep the matcher tight so only this call pauses.

   To pause just the next call once, choose **Break on Next Request** instead. It adds a request-only breakpoint for that method and URL and removes it after one request has paused, so there's nothing to clean up. (added in Cloak Proxy 0.2.0)

   *[Screenshot: The Breakpoint tool with a rule matching one endpoint and Pause on Request and Response checkboxes. A breakpoint scoped to one endpoint.]*

2. Trigger the call. The **Breakpoint** window opens with the request held.

   *[Screenshot: A request paused at a breakpoint, with editable method, URL, headers (including an Authorization bearer token) and body. A held request. Change any part before it's sent.]*

3. Tamper and observe. Common checks:

   | Change | What it probes |
   |---|---|
   | An `id` in the path or body to another user's | Broken object-level authorization (IDOR) |
   | Remove or alter the **Authorization** header | Missing authentication checks |
   | A `role`, `isAdmin` or price field in the body | Mass assignment / privilege escalation |
   | Oversized or malformed body | Input validation and error handling |

4. Click **Execute** to send your edit, **Cancel** to send the original, or **Abort** to drop it. If the rule also pauses the response, inspect or change what comes back.

> **Caution:**
> Tampering sends real requests to your backend. Use a test account and a non-production environment where you can. Turn the breakpoint off when you finish so you don't hold ordinary traffic.

## Replay with edits

For quicker iteration than a breakpoint, resend a captured request with changes.

1. Right-click a request and choose **Edit and Repeat…** (<kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>E</kbd>). The **Compose** window opens prefilled.

2. Change a parameter, header or token and press **Send** (<kbd>⌘</kbd> <kbd>↩</kbd>). Repeat with different values to sweep an input.

3. Decode tokens and encoded values inline: select text in a request or response, right-click, and use **Quick Preview** to decode Base64, a JWT, URL-encoding, timestamps or JSON — useful for reading a session token or a signed parameter before you tamper with it.

## Test race conditions and rate limits

(added in Cloak Proxy 0.2.0)

Some bugs only show up when the same request arrives many times at once: a coupon redeemed twice, a balance withdrawn twice, a login form with no rate limit. **Repeat Advanced** sends one captured request many times and summarizes what came back.

1. Right-click the request, such as a redeem or transfer call made with a test account, and choose **Repeat Advanced…** (<kbd>⇧</kbd> <kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>R</kbd>).

   *[Screenshot: The Repeat Advanced sheet for GET api.example.com/v1/users with Requests 10, At the same time 1 and Delay between starts 0 ms, a note about testing only servers you may test, and Close and Send 10 buttons. Repeat Advanced: how many, how many at once, and the delay between starts.]*

2. Set **Requests** (up to 10,000), **At the same time** (up to 100) and **Delay between starts** (in steps of 50 ms). For a race, send a handful at once with no delay, for example 10 requests, 10 at the same time. For a rate limit, send more, one at a time.

3. Click **Send** followed by the count. The sheet shows a progress bar, then:

   | Line | Shows |
   |---|---|
   | **Sent** | How many were sent out of the total, and how long it took. |
   | **Status** | How many of each status code came back, such as `200 × 1   409 × 9`, plus `failed ×` N for requests that got no response. |
   | **Time** | Minimum, average, p95 and maximum response time. |

4. Click **Show in Traffic List** to select the new requests. They appear under the app **Cloak Proxy (Repeat)**, and each went through your debugging tools.

More than one success for an action that should happen once points to a race condition. All `200`s where you expected `429 Too Many Requests` points to a missing rate limit. **Stop** cancels a run that's still sending.

> **Only against servers you may test:**
> Hundreds of requests at once can lock accounts, trigger fraud checks, run up bills or take a service down. Send them only to servers you own or have written permission to load, preferably a test environment.

## Check headers and secrets

Open **Insights** (<kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>I</kbd>) to review the responses in bulk.

1. On the **Security** tab, read each host's A–F grade and issues: missing HSTS/CSP/`nosniff`/clickjacking protection, cookies without **Secure**/**HttpOnly**/**SameSite**, wildcard CORS with credentials, and disclosed software versions.

   *[Screenshot: The Security tab grading hosts A to F with a detailed issue list for one host. Security grades and the specific header and cookie issues behind them.]*

2. On the **Secrets** tab, look for keys, tokens in URLs, card numbers and credentials over plain HTTP. Values are masked; click **Show Request** to see where each came from. See [Find leaked secrets](https://docs.subcloak.com/cloak-proxy/guides/find-leaked-secrets/).

## Tamper without code using Rewrite

(added in Cloak Proxy 0.2.0)

To apply the same change to every matching request or response, start with the [Rewrite](https://docs.subcloak.com/cloak-proxy/tools/rewrite/) tool. Each rule is a list of actions, with no script to write.

1. Right-click a captured request and choose **Tools › Rewrite…**, or open **Tools › Edit Rewrite Rules…** (<kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>R</kbd>) and add a rule. To affect only your app's traffic, type its name in **Only these apps**.

   *[Screenshot: A Rewrite rule for GET api.example.com/v1/users limited to MyApp, with actions that set the Authorization request header, remove the debug query parameter, set the response status to 503 and replace active true with active false in the response body. A Rewrite rule: each action changes one part of the request or response.]*

2. Click **Add Action** and pick what to change:

   | Probe | Action |
   |---|---|
   | Replay as another user | **Request header** › **Set** `Authorization` to a second test account's token |
   | Missing authentication | **Request header** › **Remove** `Authorization` |
   | Hidden parameters | **Query parameter** › **Set** `debug` or `admin` to `true` |
   | Client-side trust | **Response body** › **Find and replace** `"isAdmin": false` with `"isAdmin": true`, to see what the app unlocks |
   | Error handling | **Response status** › **Set** to `500` or `503` |

3. Use the app and watch the traffic list. Actions run in order, before Scripting and breakpoints.

Use Scripting, below, when a change needs logic, such as a value computed from the request.

## Script systematic tampering

To apply the same change across every matching request (not one at a time), use the Scripting tool. Scripts run `onRequest` before a request is sent and `onResponse` before the app sees it.

1. Open **Tools → Scripting**, add a rule, and set its matcher to the host or path you're probing.

   *[Screenshot: The Scripting tool with an onRequest/onResponse template, Run toggles, Check Syntax, Snippets and a Console. Scripting: change every matching request or response in JavaScript.]*

2. Write the change. For example, strip the auth header to test whether endpoints enforce it, or flip a flag in every response to see what the client exposes:

   ```javascript
   function onRequest(context, url, request) {
     // Probe missing-auth handling across every matching call:
     delete request.headers["Authorization"];
     return request;
   }

   function onResponse(context, url, request, response) {
     // response.body is an object for JSON
     console.log(response.statusCode, url);
     return response;
   }
   ```

3. Click **Check Syntax**, watch the **Console** for `console.log` output, and read the results in the traffic list (scripted flows are tagged **Script**). `sharedState` persists across scripts (for example to carry a token between calls) until you **Reset sharedState**.

> **Caution:**
> A script that removes auth or changes bodies affects **every** matching request while the tool is on. Scope the matcher narrowly, watch the traffic, and turn Scripting off the moment you're done.

## Record findings

1. Highlight and comment interesting requests: right-click → **Highlight** by color, and **Add Comment…**.

2. Export the evidence for your report. Use **Insights → Export Report** for a Markdown summary, or export the relevant requests as HAR with **Redact secrets** ticked so you don't leak live tokens into the report. Highlights and comments go with them: HAR keeps comments in the standard `comment` field, and session files keep both. Redaction doesn't change comment text, so keep secrets out of your comments.

3. Export the tool rules you used (**Tools → Export Rules…**) so a teammate can reproduce the test.

> **This is not a substitute for a professional test:**
> Cloak Proxy helps you find and demonstrate issues, but it is one tool, not a full security assessment. For a thorough review of a product that matters, bring in a professional. Subcloak, which makes Cloak Proxy, uses it in its own [security testing](https://subcloak.com/testing): AI-fast, human-proven, with a signed report.

## Clean up

1. Turn off **Breakpoint**, **Rewrite**, **Scripting** and any other tool you enabled, and **Reset sharedState**.

2. Delete or disable the probing rules so they don't fire later.

3. On a device, remove the Wi-Fi proxy and profile when you're done.

## Related

  - [Breakpoint](https://docs.subcloak.com/cloak-proxy/tools/breakpoint/): Pause and edit requests and responses.
  - [Rewrite](https://docs.subcloak.com/cloak-proxy/tools/rewrite/): Change headers, parameters, status and bodies without code.
  - [Scripting](https://docs.subcloak.com/cloak-proxy/tools/scripting/): The full onRequest/onResponse API and sharedState.
  - [Find leaked secrets](https://docs.subcloak.com/cloak-proxy/guides/find-leaked-secrets/): The secret scanner and security grades in detail.
