DNS rebind bypasses IP check
Review this Java image-proxy that blocks internal IPs.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1String fetch(String rawUrl) throws Exception {
2 URL url = new URL(rawUrl);
3 InetAddress addr = InetAddress.getByName(url.getHost());
4 if (addr.isSiteLocalAddress() || addr.isLoopbackAddress()) {
5 throw new SecurityException("blocked");
6 }
7 try (InputStream in = url.openStream()) {
8 return new String(in.readAllBytes());
9 }
10}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.