Skip to content

Commit aabf1f2

Browse files
kris7tSpecialAro
authored andcommitted
Update dependencies and fix local server directory traversal
1 parent 56d1431 commit aabf1f2

File tree

3 files changed

+62
-6
lines changed

3 files changed

+62
-6
lines changed

app/Controllers/Http/ServiceController.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const Helpers = use('Helpers');
66
const { v4: uuid } = require('uuid');
77
const path = require('path');
88
const fs = require('fs-extra');
9+
const sanitize = require('sanitize-filename');
910

1011
class ServiceController {
1112
// Create a new service for user
@@ -231,10 +232,21 @@ class ServiceController {
231232
}
232233

233234
async icon({ params, response }) {
234-
const { id } = params;
235+
let { id } = params;
236+
237+
id = sanitize(id);
238+
if (id === '') {
239+
return response.status(404).send({
240+
status: "Icon doesn't exist",
241+
});
242+
}
235243

236244
const iconPath = path.join(Helpers.tmpPath('uploads'), id);
237-
if (!(await fs.exists(iconPath))) {
245+
246+
try {
247+
await fs.access(iconPath);
248+
} catch {
249+
// File not available.
238250
return response.status(404).send({
239251
status: "Icon doesn't exist",
240252
});

package-lock.json

Lines changed: 45 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"description": "Ferdium server to replace the default Franz/Ferdi server.",
66
"main": "index.js",
77
"engines": {
8-
"node": "16.15.0",
9-
"npm": "8.7.0"
8+
"node": "16.15.1",
9+
"npm": "8.13.2"
1010
},
1111
"scripts": {
1212
"prepare": "is-ci || husky install",
@@ -45,6 +45,7 @@
4545
"mysql": "2.18.1",
4646
"node-fetch": "^2.6.7",
4747
"pg": "^8.0.3",
48+
"sanitize-filename": "1.6.3",
4849
"semver": "7.3.5",
4950
"sqlite3": "^4.1.0",
5051
"targz": "^1.0.1",

0 commit comments

Comments
 (0)