Skip to content

root-ubuntu.sh: second runs keep the kernel hardening; /root is never taken for dotfiles - #201

Merged
ralyodio merged 1 commit into
masterfrom
root-ubuntu-sysctl-dotfiles-fix
Oct 19, 2026
Merged

ralyodio merged 1 commit into
masterfrom
root-ubuntu-sysctl-dotfiles-fix

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Fixes the two bugs the root-w3bs-os.sh port found (#198), as Anthony asked ("fix them").

1. Kernel hardening lost at the next boot.

  • Run 1 raised the sysctl keys that were below the floor and wrote /etc/sysctl.d/62-profullstack-confine.conf.
  • Run 2 saw the already-raised running values, decided there was nothing to raise, and deleted the file, so the box booted without the hardening.
  • Fix: a key that sits at the floor because our own file put it there keeps its line, and so does fs.suid_dumpable = 0.

2. Root's shell config copied into every account.

  • The documented way to run the script is from /root. On run 2, the .zshrc that run 1 put there made /root look like a dotfiles checkout.
  • Fix: the script's own directory only counts as dotfiles when it is a git checkout. Running from inside a real dotfiles repo still works.

Tests:

  • Regression tests for both: the floor kept from our own file, suid kept, /root with a .zshrc rejected, a real git checkout accepted.
  • The existing suid test now sets CONFINE_SYSCTL_CONF instead of rewriting the function with sed. Otherwise it would have silently written to the real /etc.
  • vitest run test/root-ubuntu.test.ts: 193 passed. No new shellcheck warnings.

These are the same fixes root-w3bs-os.sh ships.

🤖 Generated with Claude Code

…/root for dotfiles

Two flip-flops found while porting this script to W3BS OS (root-w3bs-os.sh, #198):

- sysctl floors: run 1 raised the keys below the floor and wrote
  62-profullstack-confine.conf; run 2 saw the raised running values, wrote nothing and
  DELETED the file, so the next boot lost the hardening. A key at the floor because of
  our own file now keeps its line (same for fs.suid_dumpable = 0).
- dotfiles: run from /root (the documented way), run 2 found the .zshrc run 1 put there,
  took /root for the team's dotfiles and copied root's shell config into every account.
  The script's own directory now counts only when it is a git checkout.

Regression tests for both; the suid test sets CONFINE_SYSCTL_CONF instead of rewriting
the function. vitest root-ubuntu: 193 passed; no new shellcheck warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

41 finding(s)

HIGH/CRITICAL: 15 | MEDIUM: 12 | LOW: 14

Severity Rule Location
HIGH py-ssrf-outbound-request dev2/dev2-site:151
HIGH py-ssrf-outbound-request dev2/dev2-site:1060
HIGH py-ssrf-outbound-request dev2/dev2-site:1789
HIGH sh-remote-script-execution root-ubuntu.sh:3262
HIGH sh-remote-script-execution root-ubuntu.sh:3263
HIGH sh-remote-script-execution root-ubuntu.sh:5164
HIGH sh-remote-script-execution root-ubuntu.sh:5168
HIGH sh-remote-script-execution root-w3bs-os.sh:3632
HIGH sh-remote-script-execution root-w3bs-os.sh:3633
HIGH sh-remote-script-execution root-w3bs-os.sh:5558
HIGH sh-remote-script-execution root-w3bs-os.sh:5568
HIGH sh-remote-script-execution root-w3bs-os.sh:5575
HIGH sh-remote-script-execution root-w3bs-os.sh:5591
HIGH sh-remote-script-execution root-w3bs-os.sh:5596
HIGH sh-plaintext-download root-w3bs-os.sh:6278
MEDIUM sql-template-interpolation dev2/dev2-site:1286
MEDIUM sql-template-interpolation dev2/dev2-site:1363
MEDIUM sh-remote-script-execution root-ubuntu.sh:5372
MEDIUM redos-nested-quantifier src/domain-free.ts:56
MEDIUM redos-nested-quantifier src/emoji.ts:167
MEDIUM redos-nested-quantifier src/icon.ts:166
MEDIUM redos-nested-quantifier src/mail.ts:1047
MEDIUM sql-template-interpolation src/users-dump.ts:487
MEDIUM sql-string-concatenation src/users-dump.ts:507
MEDIUM sql-template-interpolation src/users-dump.ts:540
MEDIUM sql-string-concatenation src/users-dump.ts:574
MEDIUM redos-nested-quantifier src/wcag.ts:556
LOW secret-generic-credential src/credentials.ts:36
LOW secret-generic-credential src/credentials.ts:53
LOW secret-generic-credential src/credentials.ts:56
LOW secret-generic-credential src/credentials.ts:61
LOW secret-generic-credential src/user-export.ts:689
LOW secret-generic-credential src/user-export.ts:695
LOW secret-generic-api-key test/credentials.test.ts:208
LOW secret-generic-credential test/mail.test.ts:141
LOW secret-generic-credential test/proxy.test.ts:69
LOW secret-generic-credential test/proxy.test.ts:85
LOW secret-generic-credential test/shorten.test.ts:36
LOW secret-database-url test/users-dump.test.ts:108
LOW secret-database-url test/users-dump.test.ts:119
LOW secret-database-url test/users-dump.test.ts:120

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio
ralyodio merged commit 181d072 into master Oct 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant