Changelog - 2026-09-09
A url from user input can no longer reach inside your network
Security Behavior ChangeIn one line. A plain fetch(url) on a url your users supplied lets them reach your cloud credentials or internal services; UrlIngest.fetchGuarded does not.
ts
import { UrlIngest } from '@venizia/ignis-helpers';
const response = await UrlIngest.fetchGuarded({ url: untrustedUrl });What changed
- Non-public addresses are refused. A literal address, every resolved address (not the name), an IPv4 address wrapped in IPv6, and every redirect hop are checked. One internal A record rejects the whole host.
- The body is capped. The read cancels the moment
maxBytesis crossed. - Per-call policy.
allowedSchemes(default['https:']),allowPrivateAddress(defaultfalse; turning it on in a path that takes user input re-opens the hole),allowedHosts(when set, nothing outside the list passes),maxRedirects(3),timeout(10 seconds, anIDuration) andmaxBytes(10 MB). - Two halves.
UrlPolicy.assertSafeUrlneeds no network and is browser-pure, from@venizia/ignis-helpers/core.UrlIngestneedsnode:dnsand lives on the root barrel. - Refusal versus failure. Every refusal carries
core.url_safety.url_refused.isUrlRefusedError({ error })tells a permanent refusal (do not retry) from a timeout, DNS failure or 5xx (worth another attempt). Retry policy stays yours. AssetIngest.fromUrl. Stores a remote object without buffering it, from@venizia/ignis/static-asset. It refuses oncontent-lengthbefore the write starts, and a body that lies is caught mid-flight, so no orphaned multipart parts are left. It returns{ upload, stat }and writes no meta link. The stored content type comes from the object KEY, never from the remote host. There is no queue; you call it from whatever worker you already run.IStorageHelper.writeStream(Behavior Change). It was aBunS3Helpermethod and is now on the interface, with a base implementation that buffers and aBunS3Helperoverride that does not. It takesmaxFolderDepth, defaulting to the same depth ruleuploadapplies.
ts
const { upload, stat } = await AssetIngest.fromUrl({
helper,
url: entry.imageUrl,
bucket: { name: 'assets' },
policy: { allowedSchemes: ['http:', 'https:'] },
resolveKey: () => `${organizerId}/images/${crypto.randomUUID()}.png`,
maxFolderDepth: 3,
normalizeLinkFn: ({ object }) => buildObjectLink(object.key),
});Who is affected
- You fetch a url that came from user input. Move to
UrlIngest.fetchGuarded. This is the one that matters. - You want remote objects stored.
AssetIngest.fromUrlis new; nothing changed under you. - You wrote your own
IStorageHelper. You inherit the bufferingwriteStreamfromBaseStorageHelper. Override it if your backend takes a stream. - Everyone else. Nothing to do.
Details
- Not closed. Between the address check and the connect, DNS can answer differently (a rebinding window). Closing it needs a connect-by-address that no
fetchAPI exposes. The guard narrows the attack to that window; it does not shut it.