Potential fix for code scanning alert no. 4: Server-side request forgery#6
Merged
arjunkomath merged 1 commit intomainfrom Feb 9, 2026
Merged
Potential fix for code scanning alert no. 4: Server-side request forgery#6arjunkomath merged 1 commit intomainfrom
arjunkomath merged 1 commit intomainfrom
Conversation
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Potential fix for https://github.com/techulus/cloud/security/code-scanning/4
General approach: keep the hostname fixed (already true:
hub.docker.comandregistry-1.docker.io) and ensure that any user-controlled URL components (such astag,digest, orreference) are validated or normalized before interpolation. For a Docker image validator, the main need is to ensure thattaganddigestconform to Docker’s allowed formats and that no path traversal or control characters sneak into the URL.Best concrete fix here: introduce a simple validator for the
reference(which is either a tag, a digest, or the constant"latest") and refuse to make the outbound request if it doesn’t match an expected pattern. We can implement this as a small helper (e.g.,isValidImageReferencePart) that uses a conservative regular expression to restrict the tag/digest to allowed characters and length. Then, just after computingreferenceinvalidateDockerImage, we call this helper; if validation fails, we return{ valid: false, error: "Invalid image tag or digest" }before constructing theurland callingfetch. This change only affects the logic inweb/actions/projects.tsand does not alter existing external behavior for valid images, it just rejects invalid ones earlier and removes the tainted data from the URL building step.Concretely:
parseImageReference(within the same file) that checksreference(tag/digest) against a whitelist regex.validateDockerImage, immediately afterconst reference = digest || tag || "latest";, insert a validation step using this helper.fetchURL.No external packages are strictly required; a simple regex-based check using built-in JS facilities is enough.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.