-
Notifications
You must be signed in to change notification settings - Fork 11.5k
fix: add URL validation for logo fields #26522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add URL validation utility for server-side fetched URLs - Validate logo URLs in tRPC organization schema - Validate logo URLs in API v2 team DTOs - Add graceful fallback in logo route for invalid URLs - Only allow HTTPS and image data URLs - Add unit tests for URL validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 9 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/lib/ssrfProtection.ts">
<violation number="1" location="packages/lib/ssrfProtection.ts:24">
P1: Missing RFC 6598 Carrier-Grade NAT range (100.64.0.0/10) in private IP patterns. This range is used in cloud environments (AWS VPC NAT, GCP internal services) and could be exploited for SSRF attacks to access internal infrastructure.</violation>
</file>
<file name="apps/api/v2/src/modules/teams/teams/inputs/update-team.input.ts">
<violation number="1" location="apps/api/v2/src/modules/teams/teams/inputs/update-team.input.ts:20">
P2: Missing `@IsString()` decorator. The custom `SSRFSafeUrlValidator` assumes string input but doesn't perform type checking. If a non-string value is passed, `validateUrlForSSRFSync` will throw when calling `urlString.startsWith()`. Add `@IsString()` before `@Validate(SSRFSafeUrlValidator)` to maintain the type safety that `@IsUrl()` provided.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- Add RFC 6598 CGNAT range (100.64.0.0/10) to blocked IPs - Add @IsString() decorator before custom URL validators - Add boundary tests for new IP range
keithwillcode
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pedroccastro Checks are failing
apps/api/v2/src/modules/teams/teams/validators/ssrfSafeUrlValidator.ts
Outdated
Show resolved
Hide resolved
- Export validateUrlForSSRFSync via @calcom/platform-libraries - Fix nullable/optional order in Zod schema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 issues found across 10 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/lib/zod/ssrfSafeUrl.ts">
<violation number="1" location="packages/lib/zod/ssrfSafeUrl.ts:34">
P2: Empty string `""` bypasses SSRF validation due to falsy check. The comment says "null/undefined allowed" but `!url` also passes for empty strings. Use explicit check for null/undefined.</violation>
</file>
<file name="packages/lib/ssrfProtection.test.ts">
<violation number="1" location="packages/lib/ssrfProtection.test.ts:81">
P1: Missing test for `localhost` hostname bypass in SSRF protection. The sync validator cannot resolve DNS, so `localhost` must be explicitly blocked. Add a test case: `["https://localhost/logo.png", "Blocked hostname"]` and ensure the implementation includes `localhost` in `BLOCKED_HOSTNAMES`.</violation>
</file>
<file name="packages/lib/ssrfProtection.ts">
<violation number="1" location="packages/lib/ssrfProtection.ts:44">
P1: Security: `localhost` is missing from `BLOCKED_HOSTNAMES`, allowing SSRF bypass in the sync validation function. Since `validateUrlForSSRFSync` has no DNS resolution, URLs like `https://localhost/...` will pass validation and could be used to access local services when fetched server-side.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- Add localhost to BLOCKED_HOSTNAMES for sync validation - Use explicit null check (url == null) instead of falsy check
E2E results are ready! |
- Extract validateUrlCore() to eliminate duplication between sync/async versions - Add JSDoc to all exported functions for better discoverability - Remove redundant comments that repeated function names - Simplify existing comments to be more concise
Previously if (!url) allowed empty strings to bypass validation. Now explicitly checks for null/undefined only
emrysal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool! approved!
What does this PR do?
Adds URL validation for organization logo fields to ensure only allowed URLs are accepted for server-side fetching.
Changes
ssrfProtection.tszod/ssrfSafeUrl.tsssrfSafeUrlValidator.tscreate-team.input.ts,update-team.input.ts@IsUrl()with URL validatorupdate.schema.tslogo/route.tsValidation rules
data:image/*) allowedHow should this be tested?
http://URL → should be rejecteddata:image/png;base64,...→ should work/api/logowith invalid external URL → should fallback to default logoyarn vitest run packages/lib/ssrfProtection.test.tsMandatory Tasks