Invental/Review lessons/Trust boundaries the server must hold

Trust boundaries the server must hold

Redact streamed secrets across chunk edges

Redacting a stream is not “redact each chunk”: keep back any tail that could be the start of a secret, and never cut output in the middle of a match.

01 · Before and afterThe pattern

TypeScript
// before: chunks redacted independently; "sk-ab" + "cd12" passes through
out.write(redact(chunk));

// after: hold back a tail that could still begin a secret
buf += chunk;
const safe = lastSafeCut(buf, secrets);   // no partial or straddling match before it
out.write(redact(buf.slice(0, safe)));
buf = buf.slice(safe);

02 · Run it on your appThe check

If you mask secrets in streamed logs or LLM output, what happens when a secret arrives split across two chunks?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.