Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>

Co-authored-by: Fredrik Adelöw <freben@gmail.com>
  • Loading branch information
Rugvip and freben authored Mar 5, 2022
1 parent 81e0166 commit 30d7d39
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function writeTemporaryFile(tmpDir: string, name: string, content: string) {

If the `name` of the file is controlled by the user, they can for example enter `../../../../etc/hosts` as the name of the file. This can lead to a file being written outside the intended directory, which in turn can be used to inject malicious code or other form of attacks.

The recommended solution to this is to use `resolveSafeChildPath` from `@backstage/backend-common` to resolve the file path instead. It makes sure that the resolved path does not fall outside the provided directory. If you simply what to validate whether a file path is safe, you can use `isChildPath` instead.
The recommended solution to this is to use `resolveSafeChildPath` from `@backstage/backend-common` to resolve the file path instead. It makes sure that the resolved path does not fall outside the provided directory. If you simply want to validate whether a file path is safe, you can use `isChildPath` instead.

The insecure example above should instead be written like this:

Expand Down Expand Up @@ -103,7 +103,7 @@ res.send({ ok: true }); // BAD
res.json({ ok: true }); // GOOD
```

If you absolute must return a string with `.send(...)`, use an explicit and secure `Content-Type`:
If you absolutely must return a string with `.send(...)`, use an explicit and secure `Content-Type`:

```ts
res.send(`message=${message}`); // BAD
Expand Down

0 comments on commit 30d7d39

Please sign in to comment.