Back to the blog
How it works

Behavior Contracts: Fixing an Open Security Group Without Breaking Prod

November 24, 2026 · PosturaNet · 6 min read

Security Hub control EC2.19 fires on a security group that allows SSH from anywhere. The fix everyone reaches for is to delete the 0.0.0.0/0 rule. Sometimes that's right. Often, something real was connecting through it: a bastion, a CI runner, a partner's nightly job. Delete the rule and they break, the change gets rolled back, and the finding sits in the backlog for another quarter.

Ask the logs, not the ticket

PosturaNet starts from what actually connected. For a security group it reads the VPC flow logs, everything the account keeps up to 400 days, and groups the accepted connections by source and port. In our benchmark case that gives five sources over 89 days:

10.0.5.9/32 6,218 conns · 22/tcp · daily
10.0.4.12/32 6,002 conns · 22/tcp · daily
10.0.4.37/32 5,756 conns · 22/tcp · daily
203.0.113.7/32 1,067 conns · 22/tcp · daily at 02:00 UTC ! external, review owner
198.51.100.23/32 3 conns · 22/tcp · one_off ! not kept, likely a scanner

Three internal sources connect every day, so they stay. The outside address connects every night at the same time, which looks like a partner job, so it stays but is flagged for the owner to confirm. Three connections from an unknown address, once, look like a scanner, so that source isn't kept.

Write it down as a contract

That judgment becomes a file in your repo: a behavior contract. It lists what must stay allowed (the four kept sources) and what must stay denied (SSH from anywhere). You review it and merge it like any other code, so the decision about the partner job is made by a person who knows the partner, not by a tool.

Compute the fix, then check it

With the contract in hand, PosturaNet computes the smallest set of rules that allows every must_allow and denies every must_deny, and checks it with the Z3 solver before any PR opens. The result states its model scope, meaning what the check covered and what it didn't. Then it runs your own plan, read-only, to make sure the change touches only that security group and doesn't replace it. If any of that fails, it stops and opens no PR.

The contract keeps working after the fix

The same contract checks every later change to that security group, whether a person or an AI agent writes it. In CI, posturanet contract check returns PASS, BLOCK or UNKNOWN, so a change that would quietly drop the bastion's access fails before it merges.

What it can't see

Logs only show what happened. A disaster-recovery path that hasn't run inside the window won't be in the contract, and the PR says so in its unknowns, so the reviewer knows what to ask. With no logs at all, PosturaNet doesn't guess: it stops and tells you which logs to turn on.

Read more in the docs: behavior contracts and evidence.