Files
2026-10-29 10:55:49 +03:00

13 KiB

Starpost handoff — 2026-10-25

Confirmed vulnerabilities

Fresh-buyer cargo purchase

The checker creates flag-bearing products priced within the 200-credit budget of a newly registered buyer: the account starts with 100 credits and its one-time promo adds 100. An attacker can therefore register a buyer, credit the issued promo, buy an active product, wait for automatic warehouse delivery, and read its cargo through GET /api/orders without bypassing authentication.

Incident logs and aggregate database checks confirmed this exact path. The observed attacker used register -> account -> promo/credit -> direct buy -> orders, while the checker uses promo/credit -> promo/invalidate -> cart -> checkout -> orders.

The temporary purchase gate that returned 409 while a promo row remained was removed after the checker reported an unexpected status from POST /api/products/{id}/buy. It was not an effective confidentiality boundary because an attacker could call the public invalidate endpoint and reproduce the checker flow. Direct buy and checkout again accept buyers with an uncredited or credited promo row when their balance is sufficient; atomic one-time promo credit remains enforced.

The cargo disclosure remains open because attacker and checker use the same public purchase workflow. One-time promo credit prevents balance replay but is not a confidentiality boundary. A permanent fix requires a checker-compatible non-public purchase capability or moving flags out of buyer-deliverable cargo.

Cross-seller review cursor BOLA

Before the patch, GET /api/seller/reviews skipped the cursor HMAC check when limit <= 3. An authenticated seller could supply unsigned Base64url JSON containing another seller_id, is_private=true, and a high last_id; the response returned that seller's private review bodies.

The local baseline reproducer used synthetic seller IDs and a synthetic private-review marker. The endpoint returned HTTP 200 and disclosed the marker. The flag route before the patch is a checker-created private review body returned through the forged cursor; no real flag was used.

Contract IDOR, arbitrary file read, and cross-seller deletion

Before the patch, a seller could request GET /api/contract?file=contract-<other-id> to receive another seller's PDF. Other absolute or relative file values were resolved as filesystem paths and returned when readable. POST /api/contract similarly accepted another seller's numeric X-Contract-Id and deleted matching PDFs.

The local baseline reproducer disclosed both a synthetic victim contract and a controlled file outside the contract directory. The flag route before the patch is the seller signature embedded uncompressed in the checker-created contract PDF; no real flag was used. Destructive behavior was tested only with disposable local files.

Contract probe worker and database exhaustion

The provided capture showed sustained authenticated GET /api/contract probes at modest bandwidth. Before this patch, each foreign alias reached a new PostgreSQL connection and owner query before returning the existing 404 response. Concurrent probes could therefore occupy all synchronous API threads and delay normal registration and health requests.

The route now rejects foreign aliases, malformed filenames, and foreign deletion IDs before opening PostgreSQL. Repeated legitimate reads use a bounded process-local cache for the seller's immutable contract metadata. Existing routes, response formats, no-query reads, empty file reads, exact stored filenames, the own-ID alias, and own-contract deletion are preserved. No nginx, IP, URI, rate-limit, or other traffic filter was added, and no DoS sploit was created.

Reusable promo credit

Before the patch, POST /api/promo/credit increased the buyer balance without recording consumption. Repeating the same valid code credited the balance again because invalidation was a separate optional request.

The local baseline reproducer started with a synthetic balance of 100 and two identical credit requests both returned HTTP 200, leaving a synthetic balance of 300. This permits unauthorized value creation and can fund purchases of checker-created cargo.

Affected code before the patch

  • api/app.py: seller_reviews, get_contract, credit_promo, order_product, and checkout.
  • api/database.py: startup migration removed promo consumption state.
  • db/init.sql: promo_codes had no consumption field.

Minimal patch

  • Emergency cargo containment records a cargo_entitled decision on every new order. The buyer account must be created from zero to three seconds after the product, and the order transaction must begin within five seconds of product creation. Live checker-like failures showed buyers created after 1.021 and 1.971 seconds but orders beginning after 2.517 and 3.486 seconds, so the previous two-second purchase deadline denied otherwise valid delivered orders. A pre-staged buyer observed on a later product remained ineligible even though its order began after 0.293 seconds. Both direct buy and checkout use the same order helper. Existing entitlement decisions are immutable, and legacy orders are still backfilled with the previous two-second rule so their current/get-old behavior does not change. This is containment against pre-staged and late-created buyers, not a durable authorization boundary: an attacker that registers immediately after publication can still race the checker.
  • Cursor parsing always verifies the existing HMAC and rejects a decoded seller_id that differs from the authenticated seller. The signed cursor shape and response format remain unchanged.
  • Contract GET/POST validates ownership-shaped input before database access, resolves only the authenticated seller's database-linked filename, requires the canonical path to remain directly below /contracts, and restricts deletion to the same seller ID. A bounded cache avoids repeated owner lookups for immutable contract metadata. GET without file, GET with an empty file, GET with the exact stored filename, and the own-ID alias remain supported.
  • promo_codes.credited_at is added by a forward-compatible ADD COLUMN IF NOT EXISTS. Credit atomically transitions only an uncredited row and adds value once. A retry returns the existing 200 response shape with credited=0, allowing the existing follow-up invalidate request to continue.
  • Direct buy and checkout no longer require deletion of the promo row. This restores the original purchase contract while retaining the one-time credit transition.
  • Compose now requires independent deployment values for the PostgreSQL password, Flask session key, and warehouse callback token. generate-env.py creates three URL-safe random values in an ignored mode-0600 .env, refuses overwrite, and never prints them.

Checker and SLA invariants

  • Existing orders retain their previous cargo visibility after migration. New checker orders whose buyer was created within three seconds after the product and whose order transaction began within five seconds continue to reveal cargo after delivery and on later get-old checks. New purchases of older product IDs receive cargo=null; entitlement is stored per order, so changing deadlines later cannot reopen an old denied order and an earlier attacker order does not consume checker access.
  • Existing routes, methods, role requirements, JSON keys, public port, mounts, and warehouse flow are unchanged.
  • Existing contract filenames and files are not renamed or migrated.
  • Existing promo rows receive credited_at=NULL and remain redeemable once.
  • Both credit -> invalidate -> purchase and purchase with a remaining promo row are accepted when the buyer has sufficient balance.
  • No neighboring-service configuration is changed. Secret rotation is isolated to Starpost and keeps the existing variable names consumed by the containers.

Verification

  • Baseline synthetic results: unsigned cursor, cross-seller contract lookup, controlled external-file read, and promo replay reproduced.
  • Patched synthetic results: unsigned cursor returned 400 without executing a victim query; cross-seller and external-file reads returned 404; cross-seller deletion returned 400 and preserved the victim file.
  • Get current/get old: an existing version-2 signed cursor still returned the seller's own synthetic private review; a contract file created before patched app loading remained readable both through GET /api/contract and its exact stored filename.
  • Own mutation: deleting the authenticated seller's disposable contract still returned 200 and removed only that file.
  • Contract exhaustion regression: the pinned baseline-versus-patch matrix confirmed that foreign GET and POST probes no longer touch the database, repeated valid reads perform at most one owner lookup per process, and all preserved GET forms remain byte-identical. A separate PostgreSQL 16 integration run passed registration, login, current/get-old reads, foreign rejection, and own deletion.
  • Promo regression: first credit returned 100, retry returned 0, both kept HTTP 200, and the balance increased exactly once.
  • Purchase SLA regression: current main reproduced HTTP 409 with an uncredited promo row; the patched PostgreSQL route matrix passed direct buy before credit, direct buy after credit without invalidate, checkout after credit without invalidate, the existing invalidate flow, and preserved insufficient-balance and archived-product errors.
  • Cargo entitlement regression: a disposable PostgreSQL 16 and patched Flask API matrix accepted the two live-derived checker timings through direct buy and checkout, rejected a pre-staged buyer, rejected registration after three seconds, rejected purchase after five seconds, preserved get-old, and kept a denied order denied after timestamps changed. Only synthetic non-flag markers were used.
  • Python syntax parsing and docker compose config --quiet pass.
  • sploits/starpost_contract.py passes the GO CTF static sploit checker and a loopback synthetic runtime matrix: exit 0, only one synthetic flag candidate on stdout, diagnostics on stderr, redirect not followed, bounded timeout handled, exit 1 for invalid target, and exit 2 for wrong arguments.
  • The same sploit was run against the actual baseline route code from commit 4f70df55dd822880f4759d553f7ed249166cad86 and the current patched route with an in-memory database and temporary contract directory: baseline emitted exactly the synthetic candidate, while patched returned exit 0 with empty stdout.
  • sploits/starpost.py and sploits/starpost_warehouse.py pass the GO CTF static sploit checker. Minimal tests on the team vulnbox confirmed the issued Flask key and warehouse token were accepted; full outputs and any flag-like values were suppressed.
  • The three exploit jobs completed against the team service in under one second each during bounded validation; no real flag value was printed or stored in the repository.

Sploit handoff

  • Path: sploits/starpost_contract.py

  • Stable Neo ID: starpost-contract-idor-v1

  • Timeout: 10s

  • Input: one authorized target address; HTTP port 8090 is selected when no port is supplied.

  • Primitive: self-register a seller, enumerate a bounded window of recent numeric user IDs, request the vulnerable own-contract alias for each ID, and emit only strings matching the event flag format.

  • Path: sploits/starpost.py

  • Stable Neo ID: starpost-session-v1

  • Timeout: 10s

  • Primitive: use only the issued Flask session key to forge recent buyer/seller sessions and read their protected objects.

  • Path: sploits/starpost_warehouse.py

  • Stable Neo ID: starpost-warehouse-v1

  • Timeout: 10s

  • Primitive: use only the issued warehouse token as leaked configuration; create a normal buyer session, reuse the vulnerable promo, purchase recent products, force delivery, and read cargo.

Remaining gaps

  • The exact checker scenario and flag-bearing field are not available, so signature/PDF, private review, and cargo hypotheses are code-derived rather than checker-confirmed.
  • The API image and disposable PostgreSQL integration were tested, but the full service Compose stack, the live persistent volume, and official checker status were not. The integration used a temporary database initialized from db/init.sql and synthetic contract files.
  • The contract metadata cache is process-local. If an operator manually changes or restores users.contract_file, restart the API workers before verification so they reload that metadata.
  • Bounded requests were sent only to the team vulnbox. No request was sent to Neo, Farm, farm-submit, Skipper, or another team.
  • Deployment must rotate the existing PostgreSQL role password before recreating API/PostgreSQL containers; changing only POSTGRES_PASSWORD does not update an initialized volume.