Skip to content

Potential fix for code scanning alert no. 25: Server-side URL redirect - #83

Merged
MarkProminic merged 1 commit into
mainfrom
alert-autofix-25
Oct 1, 2025
Merged

MarkProminic merged 1 commit into
mainfrom
alert-autofix-25

Conversation

@MarkProminic

Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/STARTcloud/armor/security/code-scanning/25

To fix this server-side redirect issue, we should ensure that any user-provided path used in a redirect cannot result in a navigation outside the intended application domain/root. The best way to achieve this here is to use a robust validator, preferably encapsulated in a function (such as isLocalUrl), to ensure that the redirect is strictly local—i.e., it must remain on the same host and not encode an absolute URL or start with protocol-relative forms.

In this specific case in routes/fileServer.js, before using safeRedirectPath as a redirect target (on line 241), we should call isLocalUrl(safeRedirectPath) (the function imported from ../config/paths.js). If isLocalUrl returns true, perform the redirect; else, refuse (e.g., by responding with an error or redirecting to '/'). This is a minimal change that does not alter existing functionality beyond making the redirect secure.

Changes to make:

  • Wrap the redirect in a check: if (isLocalUrl(safeRedirectPath)) ... else ...
  • If invalid, respond with a 400 or redirect to '/'.
  • No new imports are needed, since isLocalUrl is already imported.
  • Only lines in the 227–241 range are changed.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@MarkProminic
MarkProminic marked this pull request as ready for review October 1, 2025 02:38
@MarkProminic
MarkProminic merged commit d9f5637 into main Oct 1, 2025
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant