> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sailresearch.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Run a pen-testing agent on Sail

> Build an agent in a Sailbox that periodically scans your application for vulnerabilities and reports its findings.

> [!WARNING]
>
> Only point this agent at a system you own or have **explicit written
> permission** to test. Unauthorized scanning or exploitation is illegal in most
> jurisdictions. We recommend testing a **staging or dev** environment so that
> live traffic and data are never at risk.

Give [Claude Code or Codex](#copy-agent-prompt-recommended) one prompt to set up a pen testing agent in a Sailbox. Your coding agent provisions the Sailbox, then leaves a tester running inside it on [DeepSeek](https://docs.sailresearch.com/quickstart.md) via Sail Inference. The tester maps known CVEs against the stack you point it at, checks whether your target is actually exposed, and writes up what it found. It is locked to the target you approve and stops as soon as its objective is met. The agent periodically reruns to find any new vulnerabilities.

**Once you're finished, you'll have:**

* A private Sailbox whose [egress is pinned](https://docs.sailresearch.com/sailboxes-egress-policy.md) to the single target you authorized plus the CVE feeds it reads, so it cannot reach anything else.
* An agent that reports findings and a reproduction, and that stops at the first confirmed issue instead of going further.
* Optionally, a [scheduled](https://docs.sailresearch.com/sailbox-sdk.md#cron) re-test that re-runs on a cadence you set, with a one-command kill switch.

**Why run it on Sail?**

* The agent can keep scanning for vulnerabilities forever.
* You [pay for the CPU, memory, and disk the Sailbox actually uses](https://docs.sailresearch.com/sailboxes-pricing.md).
* Inference and sandboxing both run on Sail, so every request the agent makes can be monitored from a single platform.
* Any credentials the target needs are [injected by Sail](https://docs.sailresearch.com/sailboxes-credentials), so the agent can use them without ever reading them.

## Copy agent prompt (recommended):

Paste the prompt below straight into Claude Code or Codex, or share this page with it. It asks you for the target, your authorization, and the objective before it does anything.

```text theme={null}
You are Claude Code or Codex with a shell on my machine. Help me set up an
AUTHORIZED, scoped security test in a Sail Sailbox, then leave a tester agent
running inside the box. Reference https://docs.sailresearch.com/pen-testing-agent.

First, ask me these questions and wait for my answers before doing anything else:
- Target: the host or URL I am authorized to test. Recommend a staging or dev
  environment.
- Authorization: confirm I own this target or have explicit written permission to
  test it. If I cannot confirm, stop here.
- Objective: the one concrete thing to check (e.g. "whether the login API is
  vulnerable to any known CVE in its published stack").
- Credentials: whether the target needs a login to reach the objective.
- Schedule: whether to re-run the test on a cadence, and if so how often.

Then, using my answers:
1. Install the Sail CLI if it isn't present
   (curl -fsSL https://cli.sailresearch.com/install.sh | sh) and run
   `sail auth login`. When a browser sign-in is needed, stop and tell me exactly
   what to open; never guess or enter my credentials.
2. Create the Sailbox with the Sail SDK. Set visibility to "private" so only I
   can operate it, and lock egress to ONLY the target and the CVE sources:
       import sail
       sb = sail.Sailbox.create(
           visibility="private",
           egress_policy=sail.EgressPolicy.allow_only(
               "<target host>",   # the target I gave you
               "nvd.nist.gov", "cve.org", "api.github.com",
           ),
       )
   Private visibility matters: the default lets any credential in my org exec on
   the box and read its reports. Then verify the boundary: a request from the box
   to any other host must fail before you continue.
3. If the target needs credentials, set them up with Sail credential injection
   (https://docs.sailresearch.com/sailboxes-credentials) so the tester can use
   them without reading them. Never print a credential or write one in plaintext
   on the box.
4. Write a small tester script in the Sailbox that calls DeepSeek on Sail
   Inference (use my Sail API key as an OpenAI-compatible endpoint; see
   https://docs.sailresearch.com/quickstart). It should identify the target's
   published stack, look up known CVEs that apply to it, and check whether the
   target is actually exposed. Use the lightest non-destructive request that
   proves it. Throttle requests; no destructive or high-volume tests.
5. Run it once. It must STOP at the first confirmed finding: do not exploit
   further, move to other hosts, exfiltrate data, or install anything persistent.
6. Write a report: what you checked, what (if anything) is exposed, the CVE or
   issue, a minimal reproduction, and a suggested fix.

7. If I asked for a recurring test, schedule it with a cron job that runs the tester script you wrote in step 4, using the exact path where you saved it:
       sb.cron.add(schedule="0 3 * * *", command=f"python {script_path}")

   Keep requests throttled. Then tell me the kill switch, which clears the
   schedule and sleeps the box:
       for job in sb.cron.list():
           job.remove()
       sb.sleep()

Stop and ask me before doing anything outside this scope. Tell me what you tested
and what still needs a human check.
```
