GHSA-5WP5-HFP3-JC4H
Unguarded SSRF in createSite build.siteFiles, the sibling path the build.files fix did not reach
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-5WP5-HFP3-JC4H divulgada · CVSS 7.1 (GitHub) | |
| Remediación | Parche 26.8.1 | @haxtheweb/haxcms-nodejs · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`createSite` has two separate remote-import paths, and only one of them got the SSRF hardening. `build.files` runs through `HAXCMSFile.save()`, which resolves the hostname and rejects private and reserved addresses, checks the extension against an allow-list, and sniffs the content type. That is the path GHSA-q862-gcgq-5m6g was about. About thirty lines further down in the same request handler, `build.siteFiles` calls `fetch()` on an attacker-supplied URL with none of that, and writes the response body into the new site's directory, which is served statically.
Where it is
`src/systemRoutes/v1/routes/createSite.js`, the block starting at line 752, quoted from HEAD:
// download user-customized theme and custom files (imported from another instance)
const siteFiles = req.body['build'] && req.body['build']['siteFiles'] ? req.body['build']['siteFiles'] : null;
if (siteFiles && typeof siteFiles === 'object') {
for (const relativePath in siteFiles) {
const normalizedPath = normalizeSiteFilePath(relativePath);
if (!normalizedPath) {
continue;
}
const downloadUrl = siteFiles[relativePath];
try {
const response = await fetch(downloadUrl);
if (response.ok) {
const content = await response.text();
const targetPath = path.join(site.siteDirectory, normalizedPath);
await fs.ensureDir(path.dirname(targetPath));
await fs.writeFile(targetPath, content);
}
} catch (e) {}
}
}`normalizeSiteFilePath()` does its job. It rejects `..`, null bytes and absolute paths, and it requires the key to start with `theme/` or `custom/`, so this is not a path traversal. The gap is `downloadUrl`, which nothing looks at before it reaches `fetch()`.
The sibling loop immediately above it, ending at line 751, is the contrast:
"tmp_name": downloadLocation,
"path": downloadLocation,
"bulk-import": truethat branch only accepts a staged local path that already exists under `HAXCMS.configDirectory/tmp/imports`, checked by `isValidBulkImportStagedPath`, and it goes through `HAXCMSFile.save()`, where `validateUrlNotSSRF()` lives:
var result = await dns.promises.lookup(hostname);
if (isPrivateOrReservedIP(result.address)) { return false; }Two paths, same handler, same "fetch a URL and save the bytes under `site.siteDirectory`" outcome, one guarded and one not.
Impact
Any authenticated account that can create a site can make the server issue an HTTP request to an address of its choosing and then read the response back over the web. On a cloud-hosted instance that includes the metadata endpoint; on premises it is whatever internal service the URL resolves to. The fetched bytes land under `site.siteDirectory`, which `src/app.js` serves through `express.static`, so retrieval is a plain GET.
There is a second consequence that the already-fixed path does not have. `SAFE_BULK_IMPORT_EXTENSION_REGEX` gates `build.files` but is never applied here, and nothing sniffs the response content type, so `theme/x.html` or `custom/x.js` is accepted as readily as `theme/x.png`. That puts attacker-chosen content at a predictable, web-served path with an executable extension.
Proof of concept
With a JWT for any account permitted to create sites:
POST /system/api/v1/sites
Authorization: Bearer <JWT>
Content-Type: application/json
{
"site": { "name": "poc" },
"build": {
"structure": "import",
"siteFiles": {
"custom/meta.txt": "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
}
}
}The server fetches that URL with no check and writes the body to `sites/poc/custom/meta.txt`, which is then retrievable with a GET against the created site.
I should be straight about the verification level here. I traced this at HEAD by reading `createSite.js`, `normalizeSiteFilePath`, `HAXCMSFile.save`, `validateUrlNotSSRF` and the `express.static` wiring in `app.js`, and the code quoted above is verbatim from the current tree. I did not stand up an instance with a metadata endpoint and run the request end to end, so treat the request above as the path the code takes rather than an executed exploit.
Suggested fix
Send `siteFiles` downloads through the same guard `build.files` already uses. Export the `validateUrlNotSSRF` check from `HAXCMSFile.js` as a shared helper and call it before the `fetch()`, so hosts resolving to private, loopback, link-local or metadata addresses are rejected the same way in both places. It is worth applying an extension allow-list to what `normalizeSiteFilePath()` accepts as well, mirroring `SAFE_BULK_IMPORT_EXTENSION_REGEX`, and checking the response content type before writing.
One design note while you are in there. Any "resolve, check, then fetch separately" pattern is open to DNS rebinding, because the HTTP client resolves again. Resolving once, validating that address, and connecting to the validated address closes that for both paths.
Why I do not think this is a duplicate
GHSA-q862-gcgq-5m6g covers `build.files`, and that path is genuinely fixed at HEAD. GHSA-4fg7-f244-3j49 covers SSRF in `open-apis`, a different endpoint. Nothing published mentions `siteFiles`, and the block is still unguarded in the current tree. If you are already tracking it internally, say so and I will drop it.
Severity
`CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:N`, about 7.1. It needs an authenticated site-creating account, which is the same precondition the anchor advisory carried.
CWE-918, and CWE-434 for the missing extension and content-type checks on the write.
How I found it and a note on tooling
I was reading the patch behind GHSA-q862-gcgq-5m6g to see how far the fix reached, and checking whether every remote-fetch site in the same handler had picked up the new guard. The `siteFiles` loop had not. I used AI assistance while investigating and verified the finding myself by reading the code path at HEAD.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npm@haxtheweb/haxcms-nodejs |
Corregida | 26.8.1 | 0 d | 26.8.1 no afectada |
26.8.1Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/haxtheweb/issues/security/advisories/GHSA-5wp5-hfp3-jc4hLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
