Match a service name with contains instead of equals and a caller can pick services you never meant to reach, then make your server call them.
What goes wrong
A config server takes a service name from the caller and looks up the matching registered service. The bug is one word: it matches with contains instead of equals. Supply a short substring and you match several services at once, including ones you were never meant to name.
Each matched service has an address, discovered dynamically, that the config server will POST to as a trusted internal client. So the caller can select a whole set of internal targets by giving a substring that appears in each, and the server makes a privileged request to every address it resolved.
This is SSRF with a routing bug attached. The attacker decides which internal services get hit by choosing how loose their substring is.
The pattern
matched = registry.filter(s => s.name.contains(input));
for (svc of matched) {
post(svc.discoveredUrl, payload); // privileged internal call
}svc = registry.find(s => s.name === input);
if (!svc) {
return reject('unknown service');
}
post(svc.discoveredUrl, payload);Every gate held. The exploit path was reproduced against a negative control, the impact was calibrated, and the finding was signed report-ready.
Why it matters to you
Loose matching on an identifier is a quiet way to widen a trust boundary. You meant to look up one thing by name. Loose matching (contains, an unanchored regex, whatever was convenient) turns 'find this service' into 'find anything shaped like this,' and when the thing you found is a URL your server will call, that is a pivot into your internal network.
Check your own code
- Find lookups that resolve an identifier with contains, indexOf, or an unanchored regex.
- Match identifiers by exact equality and reject when nothing matches.
- Confirm one caller request cannot fan out to multiple internal targets.
- Treat any dynamically discovered URL your server calls as attacker-influenced.