mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
A Playwright spec found this, and it found more than it was asking about. "stored HTML is forced to a safe download on the original Meteor-Files route" expected application/octet-stream and got text/html, status 200 - a stored HTML attachment served inline, which is the stored XSS that models/lib/fileResponseSafety.js exists to prevent. That policy module is correct. It was never reached. Meteor-Files calls the storage strategy's interceptDownload, and a FALSE return means "not handled, serve it yourself" - so Meteor-Files served the file from its stored path, with its stored Content-Type, and none of WeKan's headers. What makes that a bypass rather than a harmless fallback is WHY the strategy declines. getReadStream() returns nothing when the file cannot be resolved INSIDE the storage root, which is the containment check of GHSA-4mxf-m8pq-xc9p. So `false` means "this is not a file WeKan may serve", and handing that same file to a server with no containment check of its own answers the refusal with the file. The safest possible verdict and the most dangerous outcome, from one boolean. All three strategies answer 404 and claim the request now. So does the abstract base, whose body was EMPTY - returning undefined, which Meteor-Files reads exactly as it reads false, so a strategy that forgot to override it failed open too. A strategy that forgets should serve nothing rather than serve it unfiltered. A file that is genuinely absent gets the same 404 it would have got anyway. Not logged to Admin Panel / Problems, and that is a decision rather than an omission: the same path is taken by an attachment deleted while a link to it survived, which is ordinary use, and interceptDownload cannot tell the two apart - getReadStream() reports only that it has nothing. Telling "outside the root" from "not there" is what a key would need first. The spec had also been writing its file to the wrong place. build.sh exports WEKAN_FILES_PATH_HOST, which is the path mounted into the browser CONTAINER, so a local run fell back to the spec's own default of .build/bundle/files while the server read .tools/test-writable/files. It exports WEKAN_FILES_PATH too now, so the spec exercises a file the server owns - which is what it meant to test, and without which it was measuring the bypass instead. tests/attachmentServeFailsClosed.test.cjs pins that NO interceptDownload anywhere returns false, that each refuses with a 404, that every serving strategy still goes through the single policy choke point, and that text/html is still forced to a download by type and by filename - with an ordinary image still served inline as the negative. Thanks to xet7 !