All jobs

Run a Security Audit on a Rust Service

Yes. An agent builds your Rust service in its own sandbox, checks its auth, token and LDAP code against the running binary, and writes a report, changing no code.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent clones the repository into its own cloud sandbox and reads how it is built and checked before it reads a handler. In a Rust service like lldap/lldap, the root Cargo.toml is a workspace with server, app (the Yew frontend compiled to WebAssembly), migration-tool, set-password and the crates under crates/ (access-control, auth, domain, domain-handlers, domain-model, graphql-server, ldap, opaque-handler, sql-backend-handler, validation and the rest), on edition 2024 with rust-version 1.91.0, which rust-toolchain.toml and the MSRV variable in .github/workflows/rust.yml repeat. That workflow runs cargo build --workspace and cargo test --workspace, exports the GraphQL schema with export_graphql_schema and fails when it differs from schema.graphql, runs cargo clippy --tests --workspace -- -D warnings and cargo fmt --check --all, and measures coverage with cargo-llvm-cov. Nothing in CI runs cargo audit or cargo deny, and there is no deny.toml, so advisory checking is the first thing the audit adds. The server depends on actix-web 4.12.1 with rustls 0.23 on ring, actix-web-httpauth, sea-orm 1.1.8 over sqlx, ldap3_proto 0.7, opaque-ke 0.7, jwt 0.16 with hmac and sha2, secstr for secrets in memory, lettre over rustls for mail, and reqwest 0.11.

Then it maps the trust boundaries from the code. server/src/auth_service.rs mounts the HTTP authentication API: /auth/opaque/login/start and finish, /auth/simple/login, /auth/refresh, /auth/logout, /auth/opaque/register/start and finish, and the password reset pair /auth/reset/step1/{user_id} and step2/{token}, the last two registered only when enable_password_reset is on. create_jwt signs an HS512 token with Hmac<Sha512> from the configured secret, with exp one day out and a jti, and register_jwt stores a DefaultHasher hash of it so get_logout can add it to a server-side blacklist that check_if_token_is_valid consults on every GraphQL call. The responses set a token cookie with a one-day max_age, HttpOnly and SameSite::Strict on the server path, and a refresh_token cookie scoped to the auth subpath, and the reset step two cookie lives five minutes. There is no Secure attribute, which docs/architecture.md explains: HTTPS is left to a reverse proxy, while LDAPS is served natively. crates/auth/src/access_control.rs defines Permission as Admin, PasswordManager, Readonly or Regular and encodes the rule the README states, that can_change_password lets a password manager change anyone's password except an admin's. crates/auth/src/opaque.rs configures the OPAQUE slow hash as Argon2id with a fixed salt, 50 MB of memory, one lane and a time cost of one. crates/ldap/src/password.rs refuses an anonymous bind with InappropriateAuthentication, lowercases the DN before parsing, and implements the password-modify extended operation.

Configuration is the other half. server/src/configuration.rs reads jwt_secret, ldap_user_pass, force_ldap_user_pass_reset, key_seed and key_file, aborts when both a key_seed and an existing key file are present because the choice would be ambiguous, derives the private key from the seed with ChaCha20 when only the seed is given, and tells the operator to set LLDAP_JWT_SECRET when no secret is configured. lldap_config.docker_template.toml ships key_seed = "RanD0m STR1ng" and placeholder values for the JWT secret and the admin password, and the two Docker entrypoints start as root or rootless. The audit checks each of these against what a deployment would copy unchanged, and reads verbose logging and the healthcheck listener for what they expose.

Every finding is checked against the binary. The agent runs cargo build for the server, starts it with a test configuration on SQLite, and exercises the boundaries: a POST to /auth/simple/login with the configured admin password to read the exact Set-Cookie attributes, a request to /api/graphql with no bearer and with a logged-out token to confirm the blacklist, an anonymous bind and a bind with a wrong DN form against the LDAP port, and a password change by a user in the password-manager group against an admin through GraphQL. It runs cargo audit against Cargo.lock and records each advisory with the crate and the dependency path, runs cargo test --workspace once for the baseline, and writes security-audit.md where each finding names the file and line, the request it sent and the response it got, and a severity with the reason. It changes no code.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Audit this Rust service for security problems and write security-audit.md. First read Cargo.toml, rust-toolchain.toml, .github/workflows/rust.yml, server/Cargo.toml, docs/architecture.md and the config template, and record the toolchain, the build and test commands, and what CI already checks. Map the trust boundaries from the code: the HTTP auth routes and JWT creation, refresh, logout and blacklist in server/src/auth_service.rs, cookie attributes, the bearer check in server/src/graphql_server.rs, the permission rules in crates/auth/src/access_control.rs, the OPAQUE and Argon2 parameters in crates/auth/src/opaque.rs, the LDAP bind and password-modify handling in crates/ldap/src/password.rs, and the secrets, key seed and defaults in server/src/configuration.rs and the config template. Build the server, start it with a test configuration on SQLite in the sandbox, and check each finding against it: read the Set-Cookie attributes after a login, call the GraphQL endpoint without a bearer and with a logged-out token, attempt an anonymous LDAP bind, and try a password-manager user changing an admin's password. Run cargo audit on Cargo.lock and cargo test --workspace once. For every finding give the file and line, the request and response that confirm it, a severity with the reason, and the change you would make; list what you checked and found sound as well. Do not change any file and do not open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is security-audit.md as an artifact on the session, with a download link good for an hour that reading the session again renews. It opens with how the service was built and started: the toolchain from rust-toolchain.toml, the configuration used, and what CI already enforces. Then come the findings, each with the file and line, the request sent and the response received, a severity and the change proposed: the cargo audit advisories with their dependency paths, the cookie attributes and what a deployment behind a proxy must add, the configuration defaults that must not ship unchanged, and anything the LDAP or GraphQL checks turned up. A last section lists what was tested and found sound, such as the anonymous bind refusal, the token blacklist on logout and the password-manager rule.

The session read at GET /o/{org}/sessions/{id} lists the artifact with its name, mime_type and url, and the transcript at GET /o/{org}/sessions/{id}/messages keeps every build, every request the agent sent to the running binary with its response, and the cargo audit output, so each finding can be replayed. The repository is unchanged.

A reader then decides which findings are configuration guidance for their deployment and which are code changes, and a follow-up on the same session can open the code changes as a pull request with the tests to match.

Run it on every release branch

Add an automation to the Project with this prompt and a github trigger on pull_request.opened and pull_request.synchronize with branch_patterns set to release/*, so the audit runs on every pull request into a release branch and the report is ready before the tag. The trigger adds the pull request event after the prompt and fills in nothing; only pull requests by someone who can write to the repository fire it, and the automation's max_runs_per_hour, between 1 and 30, caps how many run in an hour.

For a standing cadence instead, a schedule trigger with cron set to a weekday morning audits the default branch, which also catches a new RustSec advisory against an unchanged Cargo.lock. From your own release script, send POST /o/{org}/sessions with this body and a request_id that is a UUID v5 of the release tag, give the key a webhook_url, and Rush POSTs run.completed with data.session_url to read for the artifact.

The use case this job follows, with its automation and trigger: Produce a report or file, no repo.

Why run it on Rush?

An audit of an authentication server is only worth reading when each claim was tested against the running binary: the cookie flags as actually set, the blacklist as actually consulted, the LDAP bind as actually refused. That needs the toolchain the repository pins, a build of the workspace, a started server on two ports and an LDAP client, which the agent sets up in its own sandbox and throws away afterwards.

The report carries its evidence: the request and response behind every finding, the advisory output, and the list of what was checked and found sound, with the full transcript on the session. Nothing in the repository changes, several branches can be audited at once in separate sandboxes, and the sandbox parks with its build when the turn ends, so a request to fix one finding is a follow-up rather than a second build.

Frequently asked questions

Will it change code or open a pull request?

No. The prompt forbids both. The run builds, starts and probes the service and writes the report. A follow-up on the same session can turn a chosen finding into a pull request with a test, once a person has read the evidence.

Does it need a real LDAP client?

It needs one in the sandbox, not one of yours. The agent installs an LDAP command-line client or uses the ldap3 crate the workspace already depends on to send a bind and a password-modify against the server it started, and records the result codes, such as InappropriateAuthentication for an anonymous bind.

Why isn't the token cookie marked Secure?

Because the server serves plain HTTP and docs/architecture.md leaves TLS to a reverse proxy, so the cookie is set with HttpOnly and SameSite::Strict but no Secure attribute. The report records that as read from auth_service.rs and from the login response, and states what a deployment must do at the proxy rather than calling it a bug in isolation.

Does it run cargo audit even though CI does not?

Yes. rust.yml runs build, test, clippy, fmt, the schema diff and coverage, but no advisory check, and there is no deny.toml. The agent runs cargo audit against Cargo.lock in the sandbox and lists each advisory with the crate and the path that pulls it in, so you can see whether it is reachable.

Can it audit the WebAssembly frontend too?

The app crate is in the workspace and builds with it, so the agent reads how it stores the token and calls /auth/refresh, and reports on that. Exercising it needs a browser against the served frontend, which the sandbox has; ask for it in the prompt or a follow-up and it adds those checks.

More Rust jobs

The same job on other stacks

Keep reading