Skip to content

Commit e474186

Browse files
committed
feat: add validation for asset request paths to prevent navigation inside adminforth folder
AdminForth/1781/image
1 parent bc34e04 commit e474186

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

adminforth/servers/express.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ class ExpressServer implements IExpressHttpServer {
224224
} else {
225225
const codeInjector = this.adminforth.codeInjector;
226226
this.expressApp.get(assetsRoute, (req, res) => {
227+
if (req.url?.includes('..')) {
228+
res.status(400).send('Invalid path');
229+
return;
230+
}
227231
const fullPath = path.join(codeInjector.getServeDir(), replaceAtStart(req.url, prefix));
228232
res.sendFile(
229233
fullPath,

0 commit comments

Comments
 (0)