How to Configure Per-hop Policy Enforcement

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up per hop policy enforcement by checking rules at each service step. This pattern makes every backend node check the caller before it runs a task. In many setups, only the front edge checks who the user is. Once a call gets inside the network, services often trust each other too much. If an attacker breaks into one app, they can move to other apps with ease. Checking rules at every step stops this free movement inside your network. How per hop policy enforcement works in practice To

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up per hop policy enforcement by checking rules at each service step. This pattern makes every backend node check the caller before it runs a task.

In many setups, only the front edge checks who the user is. Once a call gets inside the network, services often trust each other too much. If an attacker breaks into one app, they can move to other apps with ease. Checking rules at every step stops this free movement inside your network.

How per hop policy enforcement works in practice

To make this work, every service in a call chain must check two things. First, it checks the identity of the service that sent the call. Second, it checks the original human user or workload that started the request. Both actors must have the right to make that specific call.

This setup affects both service accounts and human users. An engineer might run a tool that calls an internal app. That app then reads rows from a database. With per hop checks, the database checks the app role and the engineer role. If either one lacks permission, the database blocks the read right away.

You should start with a default deny rule on every node. No service should accept a call unless an explicit rule allows that path. Teams often pass signed context tokens along the chain to share user details. Each hop checks the signature on the token before it reads the claims inside.

Keep the lifespan of these context tokens very short. If a token only lasts a few minutes, stolen tokens become useless fast. You should also scope each token to the exact path it needs to take. A token meant for the billing service should fail if sent to user storage.

How to check and audit each service step

Good logs are vital when you check rules at every step. You need a single trace ID that travels through the whole call chain. Every service writes this trace ID to its log when it checks a rule. This lets your team see the full path of any request from start to finish.

Policy Enforcement Point (PEP) + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

When you test your setup, try to make calls that should fail. Have a test app call a database without a valid user context token. Check the logs to make sure the database drops the request and records why. Run these checks often to catch drift in your service rules.

Static network rules and role checks at each hop solve only part of the problem. They check who can talk to a service at the start of a session. Still, once a session opens, static rules do not inspect the live commands inside. A user with a valid role can still run a bad query by mistake.

For example, an engineer might have permission to query a production table for support work. Network rules and token checks let the query pass through every hop. Yet those checks do not rewrite sensitive fields like emails, phone numbers, or card numbers. Static hop rules also cannot pause a drop table command for peer review. To close this gap, teams need controls that inspect live commands and mask results.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

What is the difference between edge checks and per hop checks?

Edge checks only verify the caller once at the outside border of a network. Per hop checks verify both the caller and the service path at every step inside.

Does checking rules at every hop slow down app traffic?

Checking local cryptographic signatures and cached rules takes less than a few milliseconds per step. Most teams find that the strong security gains are well worth this tiny delay.

What happens if one service in the chain drops the user context?

With a strict default deny rule, the next service in line rejects the call. This forces teams to pass full context across every service boundary in the system.

The query runs. The emails stay hidden.