File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
backend-java/.mvn/wrapper Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -131,22 +131,31 @@ public static void main( String[] args )
131131 * - Canonicalizing hostnames (removing trailing dots, normalizing case)
132132 * - Restricting to HTTPS only
133133 * - Rejecting null, empty, or invalid hostnames
134+ * - Rejecting URLs with user info (user:pass@host)
134135 *
135136 * @param url the URL to validate
136137 * @return true if the URL is allowed, false otherwise
137138 */
138139 private static boolean isAllowedUrl ( URL url )
139140 {
140- // Only allow HTTPS, and an EXACT host match after canonicalization.
141+ // Only allow HTTPS protocol
141142 if (!"https" .equalsIgnoreCase (url .getProtocol ())) {
142143 return false ;
143144 }
145+
146+ // Reject URLs with user info (user:pass@host) - SSRF protection
147+ if (url .getUserInfo () != null ) {
148+ return false ;
149+ }
150+
144151 String actualHost = canonicalizeHost (url .getHost ());
145152 // Reject null or invalid hostnames
146153 if (actualHost == null ) {
147154 return false ;
148155 }
156+
149157 // No subdomain allowed, just exact host match using pre-computed canonicalized hosts.
158+ // IP addresses and localhost are automatically rejected since they won't match allowed hostnames.
150159 return CANONICALIZED_ALLOWED_HOSTS .contains (actualHost );
151160 }
152161
You can’t perform that action at this time.
0 commit comments