Microservice architectures have overwhelmingly adopted gRPC for internal communications, but developers frequently treat the underlying Protocol Buffers binary format as an implicit security boundary. The assumption that an attacker cannot inspect or manipulate binary HTTP/2 frames without source .proto files leads directly to vulnerable endpoints exposing sensitive business logic.
When gRPC endpoints are exposed to client applications or the public web without rigorous authorization interceptors, the attack surface matches—and sometimes exceeds—that of traditional REST or GraphQL APIs.
The gRPC Attack Surface: Binary Payloads and Hidden Schemas
gRPC relies on HTTP/2 framed streams and Protocol Buffers (protobuf) for payload serialization. Unlike REST endpoints that exchange human-readable JSON payloads with standardized verbs (GET, POST), gRPC routes requests using RPC method paths formatted as /package.ServiceName/MethodName with content type application/grpc or application/grpc+proto.
Security assessments often stall at the serialization boundary. However, two primary mechanics facilitate detailed enumeration and exploitation:
- Server Reflection Protocol: If enabled, the server exposes the
grpc.reflection.v1.ServerReflectionorgrpc.reflection.v1alpha.ServerReflectionservice. This service returns compiled file descriptor sets containing full package structures, message definitions, field names, and data types directly to any caller. - Broken Object-Level Authorization (BOLA/IDOR): Microservices migrating from internal networks to edge gateways often rely on perimeter authentication while omitting fine-grained permission checks inside RPC method implementations. Because field names are indexed by field tags (numeric identifiers in the
.protoschema), callers can manipulate ID integers or UUID strings in serialized messages even without original field names.
When an authorization interceptor fails to validate caller claims against the specific requested resource ID in the protobuf payload, an attacker can access or mutate unauthorized tenant data by replacing field values in the payload stream.
Setting Up an Auditing Lab
To observe gRPC communication and test for authorization flaws, build a minimal lab environment using Go and grpcurl.
First, deploy a vulnerable target service locally using Docker or a local Go runner. Save the following code as main.go:
package main
import (
"context"
"net"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/reflection"
"google.golang.org/grpc/status"
pb "lab/accountspb" // Assume compiled proto package
)
type AccountServer struct {
pb.UnimplementedAccountServiceServer
}
func (s *AccountServer) GetAccountDetails(ctx context.Context, req *pb.AccountRequest) (*pb.AccountResponse, error) {
// INTENTIONAL VULNERABILITY: Missing check verifying if caller owns req.AccountId
if req.AccountId == "" {
return nil, status.Error(codes.InvalidArgument, "account_id is required")
}
return &pb.AccountResponse{
AccountId: req.AccountId,
Email: "[email protected]",
Balance: 9999,
}, nil
}
func main() {
lis, _ := net.Listen("tcp", ":50051")
grpcServer := grpc.NewServer()
pb.RegisterAccountServiceServer(grpcServer, &AccountServer{})
// Server reflection enabled for lab discovery
reflection.Register(grpcServer)
grpcServer.Serve(lis)
}
Ensure your lab application is running on 127.0.0.1:50051.
Next, set up your testing proxy. Configure Burp Suite to listen on 127.0.0.1:8080 with HTTP/2 support enabled. Install the gRPC Bar or Protobuf DevTools extension from the BApp Store to enable automatic decoding of binary HTTP/2 streams into editable JSON schemas inside the Repeater tab.
Schema Enumeration and Protobuf Fuzzing
Begin enumeration by querying the gRPC Server Reflection service using grpcurl. If reflection is enabled, you can extract the full API surface without offline access to .proto files.
List all services registered on the target node:
grpcurl -plaintext 127.0.0.1:50051 list
Expected output:
grpc.reflection.v1alpha.ServerReflection
lab.accountspb.AccountService
Inspect the RPC methods exposed by AccountService:
grpcurl -plaintext 127.0.0.1:50051 list lab.accountspb.AccountService
Describe the method signature and message definitions for GetAccountDetails:
grpcurl -plaintext 127.0.0.1:50051 describe lab.accountspb.AccountService.GetAccountDetails
This returns the precise schema structure:
rpc GetAccountDetails ( .lab.accountspb.AccountRequest ) returns ( .lab.accountspb.AccountResponse );
Describe the input request message to identify field types and tag numbers:
grpcurl -plaintext 127.0.0.1:50051 describe lab.accountspb.AccountRequest
Once the schema is known, invoke the service directly via grpcurl to test authorization logic:
grpcurl -plaintext -d '{"account_id": "ACC-1002"}' 127.0.0.1:50051 lab.accountspb.AccountService/GetAccountDetails
To perform systematic fuzzing and authorization testing:
- Route
grpcurltraffic through Burp Suite using the-proxyflag:grpcurl -insecure -proxy 127.0.0.1:8080 -d '{"account_id": "ACC-1002"}' target.lab:443 lab.accountspb.AccountService/GetAccountDetails - In Burp Repeater, edit JSON fields mapped by the gRPC extension to send unexpected data types (e.g., negative integers, ultra-long strings, null bytes) to identify unhandled errors.
- Test BOLA vulnerabilities by iterating
account_idvalues while holding the bearer token constant in theauthorizationmetadata header:grpcurl -H "authorization: Bearer <valid_low_priv_token>" -d '{"account_id": "ACC-0001"}' target.lab:443 lab.accountspb.AccountService/GetAccountDetails
If the response returns data for ACC-0001 despite the token belonging to a user assigned to ACC-1002, an authorization failure exists at the handler level.
Telemetry, Hunting, and Detection
Defenders should monitor both reverse proxy logs (Envoy, NGINX, Traefik) and gRPC application framework logs for pattern anomalies.
Key log fields to ingest:
http.urlorgrpc.method: Identifies the requested RPC path (e.g.,/grpc.reflection.v1.ServerReflection/ServerReflectionInfo).grpc.code: The status code returned (e.g.,OK,InvalidArgument,Unauthenticated,PermissionDenied).http.status: HTTP status code (gRPC requests typically yield HTTP 200 even when returning a gRPC-level error).user_agent: Default values likegrpcurl/v1.8.7or custom python scripts.
Splunk Search Query (SPL)
To detect schema enumeration via gRPC Reflection in production environments:
index=apigateway sourcetype="envoy:access"
| string http_url="/grpc.reflection.*"
| stats count dc(src_ip) as unique_sources by src_ip, http_url, user_agent
| where count > 5
To detect payload fuzzing or authorization scanning indicated by high error rates:
index=microservices sourcetype="grpc:application"
| search grpc_code IN ("InvalidArgument", "Unauthenticated", "PermissionDenied", "Internal")
| stats count by src_ip, grpc_service, grpc_method, grpc_code
| where count > 50
Potential False Positives
- Internal Development Services: Staging environments or health check systems using reflection will trigger reflection queries. Scope detection rules strictly to production gateways.
- Microservice Mesh Probes: Kubernetes readiness probes using
grpc-health-probewill generate regular status checks returninggrpc.code=OKunder/grpc.health.v1.Health/Check.
Hardening and Mitigation
Securing gRPC endpoints requires disabling schema exposure and enforcing authorization boundaries at every microservice boundary.
1. Disable Server Reflection in Production
Never compile or register reflection handlers in production builds. In Go, wrap reflection registration in an environment check:
// Secure configuration pattern
if os.Getenv("APP_ENV") == "development" {
reflection.Register(grpcServer)
}
In Java (gRPC Java): Remove the protobuf-redis or grpc-services dependency containing ServerReflectionService.
2. Enforce Explicit Authorization via Interceptors
Do not rely solely on edge authentication. Implement a unary server interceptor to enforce contextual authorization on every incoming request.
Go example utilizing an interceptor for context validation:
func AuthInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
meta, ok := metadata.FromIncomingContext(ctx)
if !ok {
return nil, status.Error(codes.Unauthenticated, "missing metadata headers")
}
tokens := meta["authorization"]
if len(tokens) == 0 {
return nil, status.Error(codes.Unauthenticated, "missing authorization token")
}
// Validate JWT and extract identity claims
claims, err := validateJWT(tokens[0])
if err != nil {
return nil, status.Error(codes.Unauthenticated, "invalid token")
}
// Inject validated identity into context for handler consumption
newCtx := context.WithValue(ctx, "user_claims", claims)
return handler(newCtx, req)
}
3. Implement Strict Message Schema Validation
Use protoc-gen-validate (PGV) or buf validate during code generation to automatically generate validation logic directly within protobuf stubs. This prevents unvalidated inputs from reaching service logic:
syntax = "proto3";
package lab.accountspb;
import "validate/validate.proto";
message AccountRequest {
// Enforce string format and pattern at protobuf level
string account_id = 1 [(validate.rules).string = {pattern: "^ACC-[0-9]{4}$"}];
}
Build processes should fail if protobuf definitions lack field validation constraints.
Related content
Breaking and Fixing LLM Integrations: Practical Injection and Defense
ResearchDependency CVE Triage: From SCA Noise to Safe Lab Validation
ResearchAnatomy of a Modern Supply Chain Attack — And Where Defenses Actually Break
ResearchBeyond CTF Badges: The Technical Artifacts That Actually Get You Hired in Security
Want a second set of eyes on your security posture?
Let's talk about where your real exposure is.
Book an advisory call