How Cal.com Rebuilt AppSec After Going Closed Source
How Cal.com consolidated noisy security tooling into one continuous, context-aware pull request security program with Gecko.
Gecko Security

Most gRPC security guidance stops at TLS configuration, which is a good start but not the whole picture. A mesh sidecar can verify a workload's identity and still have no opinion about whether that workload should be calling a specific RPC method. That gap between peer authentication and method-level authorization is where access control actually fails in practice. This guide covers the full stack, from mTLS cert rotation to JWT interceptor gaps to zero-trust policy enforcement at the method level.
TLDR:
tls.RequireAndVerifyClientCert and SAN validation; without both, a valid cert from the wrong workload passes the handshake and opens a lateral movement path.protoc-gen-validate is mandatory.gRPC runs on HTTP/2 and uses Protocol Buffers to serialize data between services. Where REST sends JSON over HTTP/1.1, gRPC sends compact binary frames over persistent multiplexed connections. A single TCP connection carries multiple concurrent streams, each representing an in-flight RPC call. The server pushes responses as they complete, and the client can stream requests back. This bidirectional streaming is what makes gRPC attractive for high-throughput internal service communication.
A service mesh sits underneath all of this. Sidecar proxies (typically Envoy) intercept every inbound and outbound connection at the network level, without the application code knowing. The mesh handles load balancing, retries, circuit breaking, and observability. In a gRPC context, the sidecar understands HTTP/2 frames natively, which lets it route individual RPC calls instead of raw TCP packets.
The combination creates a specific security topology worth understanding before reaching for any auth mechanism.
When Service A calls Service B in a meshed gRPC deployment, the path looks like this:
.proto schema. The binary payload goes to the local sidecar proxy, not directly to Service B.Every hop in that path is a potential enforcement point. The sidecar can terminate mTLS, inspect metadata headers, and reject calls before application code runs. Mesh configurations that forward requests without validation can also introduce server-side request forgery risks at the proxy layer. Whether those enforcement points are actually configured is where service mesh security either holds or fails.
Protocol Buffers define the contract between services. Each .proto file specifies message types, field numbers, and RPC method signatures. The binary encoding maps field values to those field numbers, so there is no field name in the wire format at all.
This has a direct security implication: a service receiving a gRPC call has no way to validate the payload against the schema unless it explicitly deserializes and checks the message. The mesh proxy passes binary frames through. If the receiving service skips validation, malformed or unexpected field values arrive silently. Unknown fields in proto3 are preserved by default instead of rejected, which means a caller can send fields the server never defined and the data will persist through serialization cycles.
gRPC services expose a distinct set of entry points that differ from REST APIs in ways that matter for security testing. The protocol uses HTTP/2 as its transport layer, which means connection multiplexing, binary framing, and persistent connections are all in scope. Reflection endpoints, when left active in production, hand an attacker a full service definition without requiring access to the .proto files. Choosing the right approach to test for these exposures comes down to understanding SAST vs DAST tradeoffs. Unary, server-streaming, client-streaming, and bidirectional-streaming RPCs each carry different risk profiles depending on how authentication is applied per-call versus per-connection.
Mutual TLS (mTLS) is the foundation of gRPC service authentication in zero-trust environments. Unlike standard TLS, where only the server presents a certificate, mTLS requires both client and server to exchange and validate certificates before any RPC call completes. Every service proves its identity at the transport layer, before any application-level auth logic runs.
When a gRPC client dials a server with mTLS configured, the handshake proceeds in both directions. The server presents its certificate; the client validates it against a trusted CA. The client then presents its own certificate; the server validates it against the same or a separate CA bundle. Only after both validations succeed does the connection open for RPC traffic.
In practice, your certificate authority strategy matters as much as your TLS configuration. Most teams run a private CA for internal service mesh traffic, issuing short-lived certificates to each service identity. Tools like SPIFFE/SPIRE automate this by binding certificates to workload identities instead of IP endpoints or hostnames, which breaks down fast in container environments where IPs churn constantly.
A minimal Go gRPC server with mTLS looks like this:
cert, _ := tls.LoadX509KeyPair("server.crt", "server.key")
caCert, _ := os.ReadFile("ca.crt")
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
ClientCAs: caCertPool,
ClientAuth: tls.RequireAndVerifyClientCert,
}
creds := credentials.NewTLS(tlsConfig)
server := grpc.NewServer(grpc.Creds(creds))Setting ClientAuth to tls.RequireAndVerifyClientCert is the critical line. Without it, the server accepts connections from any client regardless of certificate validity, which eliminates the authentication guarantee entirely.
Short certificate lifetimes reduce the blast radius of a compromised credential. If a service certificate is stolen but expires in 24 hours, the attacker's window is narrow. If it expires in two years, you have a persistent threat. Most service mesh deployments target certificate lifetimes between 1 and 24 hours, with automatic rotation handled by the mesh control plane or SPIRE agent.
The rotation problem is harder in practice than it looks. gRPC connections are long-lived by design, and a certificate rotation mid-connection requires either connection draining or support for live credential reloading. The Go credentials.TransportCredentials interface does not hot-reload by default; you need to implement a custom credentials.Bundle or use a mesh sidecar that handles rotation transparently.
| Misconfiguration | Effect | Fix |
|---|---|---|
| ClientAuth: tls.NoClientCert | Server accepts any client; no service authentication | Set to tls.RequireAndVerifyClientCert |
| Self-signed certs without a shared CA | Certificate validation fails or is skipped entirely | Issue certs from a common internal CA |
| Certificate pinning without rotation support | Rotation breaks connections silently | Use CA pinning, not leaf cert pinning |
| Long certificate TTLs (1+ years) | Compromised certs remain valid for extended periods | Target 1-24 hour TTLs with automated rotation |
| Skipping hostname verification | mTLS confirms a valid cert exists, not the right identity | Validate SANs against expected service identities |
Skipping hostname or SAN verification is particularly dangerous in gRPC service mesh deployments. A service can present a valid certificate issued by your CA but for a completely different workload. Without SAN validation, the handshake succeeds and your caller believes it is talking to the correct service. That is a lateral movement path, not an authentication guarantee.
gRPC auth is not a single mechanism but a layered composition of interceptors, credential types, and token validation logic. Getting any layer wrong leaves the others exposed.
Interceptors are the standard place to enforce authentication in gRPC. A server-side unary interceptor runs before your handler and can inspect metadata, validate tokens, and reject requests before any business logic executes. The pattern looks straightforward, but the failure modes are subtle.
The most common mistake is writing an interceptor that validates tokens on unary calls but fails to wire up a separate StreamInterceptor for streaming RPCs. gRPC treats these as distinct extension points. A service with both unary and streaming methods needs both interceptors registered, or streaming endpoints go unprotected.
JWT is the most widely used credential format in gRPC services. The interceptor extracts the token from the Authorization metadata key, verifies the signature against a known key or JWKS endpoint, checks expiry, and either populates a context value with claims or returns a codes.Unauthenticated error.
For external-facing gRPC APIs, OAuth2 bearer tokens are standard. Pairing token validation with thorough API scanning automated security testing confirms bearer tokens are exercised against every exposed method. The gRPC Go and Java libraries both include oauth credential helpers that attach tokens to outgoing calls automatically. The interceptor on the server side then validates the bearer token against your authorization server's introspection endpoint or a locally cached JWKS.
The service mesh complicates this. When a sidecar proxy like Envoy handles mTLS termination and forwards the request to your gRPC service, the original Authorization header is typically preserved, but the channel is now plaintext between the proxy and the service. Your interceptor still receives and must validate the JWT. Do not assume the proxy has done token validation unless you have explicitly configured it to do so and verified that configuration.
Once an interceptor validates a token and extracts claims, those claims need to travel with the request through the call chain. The correct pattern is to store them in the gRPC context using a typed key and retrieve them in handlers or downstream interceptors. Passing raw token strings through context and re-validating at each layer is both slow and error-prone. Extract once, propagate structured claims.
Authorization checks in gRPC services tend to follow a familiar pattern: validate the token, confirm the caller's identity, and proceed. The problem is that identity alone rarely captures what a caller is actually allowed to do in the context of a specific request.
In a service mesh, each hop between services carries its own trust assumptions. A billing service calling an inventory service may hold a valid mTLS certificate and a legitimate JWT, yet still be making a request it should never be permitted to make. This is exactly why business logic is AppSec's unsolved problem. Token validity and authorization scope are separate concerns, and conflating them is where access control breaks down.
The fix requires separating three distinct checks: is this caller who they claim to be (authentication), is this caller allowed to reach this service at all (coarse-grained mesh policy), and is this caller allowed to perform this specific action on this specific resource (fine-grained service logic). Only the last of these lives inside your gRPC service code.
gRPC reflection is a built-in service that lets clients query a server for its available services, methods, and message schemas at runtime. In development, this is genuinely useful: tools like grpcurl and Evans rely on it to construct requests without a pre-compiled proto file. The problem is that reflection frequently ships to production without any auth requirement, turning what was a developer convenience into a full service catalog for anyone who can reach the port.
An attacker with network access to a gRPC port can call grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo and receive a complete inventory of every exposed service and method. No credentials required. The response includes method names, request and response message schemas, and field types: everything needed to craft a well-formed malicious request against any endpoint in the service.
The gap between development config and production config is the root cause. Reflection is typically registered during early development alongside the main service handlers, and the registration call sits in the same server setup block as everything else.
// This block often survives into production unchanged
reflection.Register(s)
grpcServer.RegisterService(&pb.MyService_ServiceDesc, &myServiceImpl{})When engineers move fast, that reflection.Register(s) line travels with the service through staging and into production. Unlike an HTTP debug endpoint, there is no obvious visual marker that it is a separate capability with a different risk profile.
The fix is straightforward: gate reflection registration on an environment variable or build flag, and treat production as the default-off case.
if os.Getenv("GRPC_REFLECTION_ENABLED") == "true" {
reflection.Register(s)
}If reflection is genuinely needed in production for internal tooling, it should be placed behind the same interceptor chain used for sensitive service methods, requiring a valid token before the reflection service responds. Treating reflection as a first-class service with its own auth requirement, instead of a development utility, closes the exposure without removing the capability.
Protobuf schemas enforce field types at the wire level, but that enforcement is shallower than it appears. A field typed as string accepts any byte sequence the client chooses to send. A field typed as int64 won't reject a value of 9223372036854775807. The schema validates structure, not semantics, and that gap is where input validation failures live.
The Protobuf runtime hands you a deserialized struct. What you do with it is your responsibility. Field presence checks, length constraints, enum range validation, and cross-field consistency rules all need explicit application-layer enforcement.
Libraries like protoc-gen-validate (PGV) let you annotate .proto files with constraints that generate validation code:
message CreateUserRequest {
string username = 1 [(validate.rules).string = {min_len: 3, max_len: 64, pattern: "^[a-zA-Z0-9_]+$"}];
string email = 2 [(validate.rules).string.email = true];
}Without annotations like these, every service method that accepts a message is implicitly trusting the caller to send sane values, a risk that compounds when securing AI-generated code, where validation logic is often omitted entirely. In an internal mesh that assumption may hold under normal conditions. Under adversarial conditions, or after a compromised sidecar, it won't.
Zero-trust enforcement in a service mesh requires more than flipping a configuration switch. The mesh must actively reject any request that lacks a verified identity, regardless of where that request originates in the cluster. Every service becomes both a client and an enforcer.
Most teams start by deciding whether to enforce policy at the mesh level, the application level, or both. Mesh-level enforcement handles transport security and identity verification through mTLS and SPIFFE-based workload identities. Application-level enforcement handles business logic, role checks, and scoped permissions, an area where static analysis struggles with business logic vulnerabilities because no single file captures the full authorization intent. Conflating the two layers produces gaps: a service that trusts the mesh to handle AuthN may skip its own AuthZ checks entirely, assuming the calling service already had permission.
gRPC services present a specific challenge here. Because gRPC multiplexes calls over a single HTTP/2 connection, a coarse-grained policy that permits the connection will permit all RPCs on it unless the mesh inspects at the method level. Envoy-based meshes can match on the :path pseudo-header, which gRPC encodes as /package.ServiceName/MethodName, giving you method-level authorization without instrumenting every service individually.
Policy drift is the long-term risk. As services are added or refactored, authorization policies go stale. Automated policy generation from observed traffic patterns, combined with periodic policy reviews tied to service ownership, keeps the mesh's rules aligned with what the system actually does.
Binary gRPC frames carry no human-readable payload, so network-layer inspection tools see HTTP/2 streams with no actionable method or message content. The sidecar proxy closes that gap.
Every request passing through the mesh generates connection logs, per-method error rates, authorization-denied events, and latency distributions, all attributed to the specific source and destination workload. Feed those access logs into a SIEM and patterns that would otherwise be invisible become detectable. A service suddenly spiking PERMISSION_DENIED responses on methods it has never previously called is a concrete indicator of a compromised workload probing adjacent services for lateral movement. These signals are invisible to any tool operating below the proxy layer, because binary framing makes gRPC traffic opaque to network-level inspection. The same telemetry surfaces subtler signals: a service calling methods outside its normal call graph, or latency anomalies that suggest payload amplification during deserialization.
Without mesh telemetry, gRPC inter-service traffic is a black box. The binary framing that makes gRPC fast is the same property that makes it opaque to any inspection tool operating below the proxy layer.
The key is treating authorization-denied events as first-class security signals, not noise to be filtered. A single denied request means little. A denied request pattern across multiple destination services, from a single source workload, in a short time window, is lateral movement.
Cross-service authorization gaps that produce no detectable bad pattern in any single file surface as confirmed findings, each with an automatically generated proof-of-concept exploit and mapped business impact. Gecko's semantic graph traces the full call chain across service boundaries, connecting a gateway's validation logic to a downstream service's missing ownership check, while AST-based scanners see valid code at each layer and stop. This is the same cross-service reasoning behind Gecko's discovery of 30+ CVEs no other AppSec tool found.
Gecko automatically detects and analyzes gRPC and Protobuf endpoints in Scala/Java and JavaScript/TypeScript codebases, extending the same cross-service semantic analysis applied to REST APIs into gRPC service mesh architectures.
| Vulnerability Class | What Gecko Traces | Why AST-Based Tools Miss It |
|---|---|---|
| Missing authorization on gRPC methods | Call chains from gRPC handler to ownership check; flags methods where no authorization logic exists in any reachable path | No syntactic signature for a missing check; the flaw is an absent code path, not a malformed one |
| IDOR through Protobuf field access | Object access patterns through deserialized message fields; confirms ownership validation runs before resource is returned | Pattern matching cannot confirm whether an ownership check exists elsewhere in the call chain |
| Auth bypass on streaming RPCs | Interceptor registration for both UnaryInterceptor and StreamInterceptor; flags services where only one is wired up | Single-file analysis sees each interceptor in isolation and cannot compare coverage across RPC types |
| Cross-service privilege escalation | Multi-hop gRPC call chains where a caller's permission scope is trusted downstream without re-validation | The escalation path spans multiple services; no single file contains the full vulnerability |
Every concept covered here, from mTLS certificate rotation to mid-stream auth bypass to protobuf deserialization risk, maps to a real failure mode that shows up in production deployments. Your mesh telemetry, interceptor chain, and authorization policies are only as strong as the weakest layer you skipped. The good news is that each gap is fixable once you know where it is. Book time with the Gecko team to trace those gaps across your actual gRPC call chains.
Gate reflection registration on an environment variable so it defaults to off in production, and if you need it for internal tools, place it behind the same interceptor chain that protects your sensitive service methods, requiring a valid token before the reflection service responds. The root cause of most reflection exposures is that reflection.Register(s) travels unchanged from development through staging into production because it sits in the same server setup block as the main service handlers.
Both layers are necessary and cover different things. mTLS with SPIFFE-based workload identities confirms that a calling service is who it claims to be at the transport layer; JWT interceptors inside each service check what the caller is allowed to do on a specific resource. A service that trusts the mesh to handle authentication and skips its own authorization checks ends up passing every request from any authenticated caller regardless of what resource is being accessed, and that is where access control breaks down in practice.
Mid-stream auth bypass occurs when a service validates a token once at connection open but never re-checks it on subsequent messages in a long-lived streaming RPC, meaning a token revocation or expiry goes undetected while the stream stays open. The fix is to wire up a StreamInterceptor alongside your UnaryInterceptor, because gRPC treats these as separate extension points, and a service with both unary and streaming methods that only registers one leaves the other unprotected.
Semgrep operates at the file level and cannot trace authorization logic across service boundaries, so a missing ownership check in a downstream service is invisible when validation only appears at the gateway. Gecko's semantic graph traces the full call chain across services, connecting a gateway's validation logic to a downstream service's missing check, and produces a confirmed finding with an automatically generated proof-of-concept exploit, while AST-based tools see valid code at each layer and stop.
Envoy-based meshes can match on the :path pseudo-header, which gRPC encodes as /package.ServiceName/MethodName, letting you write authorization policies at the individual RPC method level without changing service code. A coarse-grained policy that only permits the HTTP/2 connection will permit every RPC on that connection, so method-level path matching in your mesh authorization policy is the correct scope for least-privilege enforcement between gRPC services.
Jeevan Jutla
Co-founder & CEO
JJ joined GCHQ as a teenager, working on security research and exploit development, and scored the highest mark on its reverse engineering and binary exploitation aptitude test ever recorded. The record still stands. He went on to lead security tool development for Binance’s eight-person red team and led the recovery of $500K stolen by North Korean state hackers, the largest recovery of stolen funds at the time.
The latest news, technologies, and resources from our team.
How Cal.com consolidated noisy security tooling into one continuous, context-aware pull request security program with Gecko.
Gecko Security
See what actually changed in the OWASP Top 10 for 2026, from merged SSRF and XXE categories to new supply chain risks and scanner coverage gaps.
Jeevan Jutla
Gecko Security uncovered CVE-2026-21894 in August 2026, an n8n authorization bypass with CVSS 8.8. See why static tools missed it and how to remediate it.
Jeevan Jutla
Security misconfiguration is OWASP A05 for a reason. Learn how deployment context determines exploitability and how to fix gaps in August 2026.
Jeevan Jutla
How do modern AppSec vendors actually compare? This July 2026 capability map covers SAST, DAST, SCA, business logic flaws, and cross-service
Gecko Security
Break down your AppSec stack: what SAST, DAST, SCA, IAST, and pen testing each see — and what they miss. Updated July 2026 by Gecko Security.
Gecko Security
Occasional updates, new content, and insights. No spam; unsubscribe anytime.