A jail that fails closed

Craft - 2 min read -

Two small parts in the Forge do the same trick. They check the thing that will actually be used, and they make every refusal look the same.

The file jail

An empty set of roots does not build. The jail's own words are that it would be a build failure, "not a jail with no walls". Roots are resolved once, and if one is later swapped for a symlink the jail refuses, so it fails closed when its ground moves.

Every containment failure returns the same error, with no path and no root in it. A caller cannot map the filesystem by telling the refusals apart. A missing final path element still resolves, on purpose, because creating a new file needs it.

The dial guard

When a program fetches a URL, the guard resolves the name once, inside the dialler, checks every address it got back, and dials an IP literal. There is no second lookup for an attacker to rebind. Redirects need no extra check, because every hop goes through the same dialler.

It refuses loopback, private ranges, carrier-grade NAT (where a private network can live), link-local addresses including cloud metadata, and unique-local IPv6. The zero value refuses.

The trick

Check the thing you will use. Say no the same way every time.

Sable