fix: validate country input to prevent SSRF vulnerability (#1302) - #1351
Open
saidai-bhuvanesh wants to merge 1 commit into
Open
fix: validate country input to prevent SSRF vulnerability (#1302)#1351saidai-bhuvanesh wants to merge 1 commit into
saidai-bhuvanesh wants to merge 1 commit into
Conversation
- Added ALLOWED_COUNTRIES whitelist with valid Adzuna country codes - Added getValidCountry() function to validate user input - Country parameter now validated before use in API URL - Falls back to default country if invalid input provided
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe job controller now validates Adzuna country codes against a whitelist, normalizes valid values to lowercase, falls back to ChangesAdzuna country validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Comment on lines
16
to
+23
|
|
||
| /** | ||
| * Validates and returns a safe country code. | ||
| * Falls back to default if invalid. | ||
| */ | ||
| function getValidCountry(country) { | ||
| if (country && ALLOWED_COUNTRIES.has(country.toLowerCase())) { | ||
| return country.toLowerCase(); |
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.
Summary
Fixed SSRF vulnerability reported in issue #1302. The country parameter was directly used in the API URL without validation.
Changes Made
Added ALLOWED_COUNTRIES whitelist - Set of valid country codes supported by Adzuna API:
in,us,gb,au,ca,de,fr,nl,be,at,pl,es,it,ch,sgAdded getValidCountry() function - Validates user input against whitelist before using in API URL. Falls back to default country code if invalid input is provided.
Updated getJobs controller - Now uses the validation function for
req.query.countryparameter.Security Fix
countryparameter directly used in URL constructioncountryvalidated against whitelist before useCloses #1302
Summary
ALLOWED_COUNTRIESwhitelist for Adzuna country codes.getValidCountry()to normalize valid codes and use the default country for invalid input.getJobsto use the validated country for API requests and caching.countryvalues from reaching the Adzuna API URL.