Skip to content
Race condition Write-up Advanced

Remote Code Execution - Rage of Race Condition on Gen AI

A race condition in a Gen AI model allowed concurrent requests to bypass input validation, enabling an attacker to execute system commands and access cloud metadata. The attacker could run arbitrary commands and make server-side requests to internal services.

medium.com

Published on medium.com

Race condition vulnerability occurs when websites process requests concurrently. Race conditions typically occurs in multi-threaded or multi-process environments where multiple threads or processes are competing for shared resources.

Jerry Shah (Jerry), on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a lack of proper synchronisation in the backend when processing concurrent requests, causing the validation layer to be bypassed for some requests.

Impact

An attacker could execute arbitrary commands on the underlying system, access sensitive data, modify or delete files, and make unauthorized requests to internal services, potentially leading to further compromise.

What the attacker needed

Access to the Gen AI interface; ability to send concurrent requests

The fix

The Gen AI should be sandboxed with strict isolation, external command execution disabled, input sanitised, race conditions mitigated with proper synchronisation, and outbound network requests restricted.

How it was found

  1. Send a simple greeting to the Gen AI and observe a normal reply.
  2. Ask the Gen AI to perform a ping to an attacker-controlled server; it refuses.
  3. Send multiple requests concurrently (race condition) asking the Gen AI to perform a ping and list a directory; the command executes.
  4. Repeat the race condition with different commands to confirm remote code execution.
  5. Use the race condition to request an internal metadata URL, achieving server-side request forgery.
  6. Further exploit by running a network statistics command to gather more system information.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A race condition happens when a system handles multiple requests at the same time and gets confused, so a security check that should block a request is skipped. Here, the AI normally refused to run commands like ping or ls, but when many requests were sent at once, one slipped through and the system actually ran the command. This let the attacker run commands on the server and reach internal cloud services.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.