mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-12-01 09:24:46 +00:00
security: harden credentials app after the 2026-10-27 dev2 incident (CLI 0.10.0)
An attacker with root on dev2 read identity.json (identity secret key + a user
lsk_ token) and used the token against app.logicsrc.com. This closes the gaps
that made that worse than it had to be, and adds the tools to recover.
Identity keys
- A registered identity public key is never replaced by a login any more
("last login wins" let a stolen token swap in an attacker key). Changing it
needs `logicsrc teams rotate-identity`: the server seals a random answer to
the CURRENT key (single use, 5 min); the CLI proves possession and re-seals
every vault grant to the new key in one transaction (POST /keys/rotate).
- Lost key: reset from a signed-in browser (Settings), which drops every grant
sealed to the old key. `logicsrc teams key --import` moves a key to a new box.
Vault re-key
- `logicsrc teams rekey <team> <project> <env>` and `--all`: new vault key,
values re-encrypted client side, re-sealed to every current member and
machine key. Server bumps credshare_vaults.key_version; writes that name a
retired version get 409, and the rekey UPDATE only touches rows whose value
did not change mid-flight. A verify pass (per vault and a final sweep)
re-seals any value a racing older client wrote under the retired key.
Key pinning (TOFU)
- CLI pins teammates' and machine keys' fingerprints in known-keys.json (0600)
and refuses to seal (grant, rekey) to a changed key without
--accept-key-change. `teams members` shows fingerprints and pin status;
the dashboard shows fingerprints and public/pins.js flags changes.
Audit
- Every person read of a vault key (/grant) and of ciphertext (/secrets) is
audited with IP and user agent (also denied reads and identity events).
GET /teams/:slug/audit, `logicsrc teams audit`, and tables on the dashboard
and vault pages.
At rest / transport
- Session tokens stored as sha256 (rows hashed in migration 007); CLI auth
codes hashed. New API keys no longer travel in the /settings URL.
- CSP (script-src 'self', no inline script or handlers, frame-ancestors none),
HSTS, X-Frame-Options, Referrer-Policy no-referrer, COOP/CORP, no-store on
authenticated pages. Inline scripts moved to /app.js and
/vendor/profile-enhance.js.
- The shared footer renders from the bundled template of a pinned
@profullstack/footer 0.5.0 (allowlist sanitizer); no runtime CDN fetch.
- Migrations can run as a separate owner role (MIGRATE_DATABASE_URL) so the
app can connect as a DML-only role with an append-only audit table.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
18477340e7
commit
ae6298851b
34 changed files with 1633 additions and 112 deletions
|
|
@ -16,12 +16,18 @@ import { cliRouter } from "./routes/cli.mjs";
|
|||
import { pagesRouter } from "./routes/pages.mjs";
|
||||
import { profileRouter } from "./lib/profile.mjs";
|
||||
import { descriptor } from "@profullstack/footer";
|
||||
import { RING_FOOTER_OPTIONS, startRingFooterRefresh } from "./lib/ring-footer.mjs";
|
||||
import { RING_FOOTER_OPTIONS } from "./lib/ring-footer.mjs";
|
||||
import { securityHeaders } from "./lib/security-headers.mjs";
|
||||
import { PROFILE_ENHANCE_SCRIPT } from "@profullstack/profile";
|
||||
|
||||
const app = express();
|
||||
app.disable("x-powered-by");
|
||||
if (config.secure) app.set("trust proxy", 1); // Railway terminates TLS
|
||||
|
||||
// Security headers on every response (CSP with no inline or third-party script,
|
||||
// HSTS, no framing, no referrer). See lib/security-headers.mjs.
|
||||
app.use(securityHeaders);
|
||||
|
||||
// body parsing — keep the raw body for HMAC signature verification
|
||||
// A vault push carries hundreds of encrypted items; parse it under a larger cap
|
||||
// first. The global parser below skips a body that is already parsed.
|
||||
|
|
@ -50,6 +56,8 @@ const sodiumWrappers = requireHere.resolve("libsodium-wrappers");
|
|||
const sodiumCore = createRequire(sodiumWrappers).resolve("libsodium");
|
||||
app.get("/vendor/libsodium.js", (_req, res) => res.sendFile(sodiumCore));
|
||||
app.get("/vendor/libsodium-wrappers.js", (_req, res) => res.sendFile(sodiumWrappers));
|
||||
// The signup profile's progressive enhancement, as a file: the CSP allows no inline script.
|
||||
app.get("/vendor/profile-enhance.js", (_req, res) => res.type("application/javascript").set("Cache-Control", "public, max-age=3600").send(PROFILE_ENHANCE_SCRIPT));
|
||||
|
||||
// The Profullstack webring descriptor (the ring footer is on the sign-in page, /).
|
||||
app.get("/.well-known/openwebring.json", (_req, res) =>
|
||||
|
|
@ -82,7 +90,6 @@ app.use((err, _req, res, _next) => {
|
|||
|
||||
async function main() {
|
||||
await migrate();
|
||||
startRingFooterRefresh();
|
||||
app.listen(config.port, () => console.log(`🔐 logicsrc credentials on :${config.port} (${config.env}) — ${config.origin}`));
|
||||
}
|
||||
main().catch((e) => { console.error("boot failed:", e); process.exit(1); });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue