Potential fix for code scanning alert no. 1: Incomplete URL substring sanitization #12
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
javascript
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Snupai/snupai-site!12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "alert-autofix-1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Potential fix for https://github.com/Snupai/snupai-site/security/code-scanning/1
To fix the problem, the referer URL should be parsed, and its
hostnameproperty compared against an explicit whitelist of allowed hostnames. For subdomain support, the allowed hostnames should be clearly listed in an array, e.g.,['snupai.me', 'www.snupai.me']. This ensures only referers from the correct hosts are accepted. Specifically, you should replace the stringreferer.startsWith('https://snupai.me')logic in theisAllowedRefererfunction (lines 26-33) with code that parses the referer URL using the built-inURLclass and checks thehostnameagainst an array of allowed hostnames.You will need to add an import for
URLif not already available (globally available in Node.js and modern runtimes), and modify theisAllowedRefererfunction to use parsed referer URLs for host validation. Only edit shown code insrc/app/api/ai-roast/route.ts.Suggested fixes powered by Copilot Autofix. Review carefully before merging.
The latest updates on your projects. Learn more about Vercel for GitHub.