Commit graph

1009 commits

Author SHA1 Message Date
Ashlen
3559bc86b7
fix(permission-hardener): ssh-agent gets 2755 perms
Change from exactwhitelist to matchwhitelist. Discussion revealed that
there's a good reason to leave setgid in here, which is essentially
defense-in-depth (sometimes users may want to revert Kicksecure's
default of kernel.yama.ptrace_scope=2, e.g. to debug a program, and
Kicksecure should not be less secure than vanilla Debian in that
situation).
2025-05-27 15:32:41 -06:00
maybebyte
c59b2e4bc5
Merge branch 'Kicksecure:master' into ssh-agent-to-allowlist 2025-05-27 20:33:07 +00:00
maybebyte
017ee29eb3
Merge branch 'Kicksecure:master' into ssh-agent-to-allowlist 2025-05-27 18:25:47 +00:00
Patrick Schleizer
5195977be4
protect against grep pipefail 2025-05-27 11:57:21 -04:00
Patrick Schleizer
395169fbce
Merge pull request #308 from maybebyte/permission-hardener-speedboost
perf(permission-hardener): optimize string match
2025-05-27 10:58:50 -04:00
Patrick Schleizer
142ea21189
fix 2025-05-21 12:42:16 -04:00
Patrick Schleizer
a969fa350e
fix 2025-05-21 12:40:27 -04:00
Patrick Schleizer
f023651c98
nounset 2025-05-21 12:35:37 -04:00
Patrick Schleizer
f086787464
fix 2025-05-21 12:35:23 -04:00
Patrick Schleizer
d7643954d1
minor 2025-05-21 12:33:50 -04:00
Patrick Schleizer
aa905fc887
further validation of output of faillock 2025-05-21 12:32:16 -04:00
Patrick Schleizer
92d3a36a0f
fix 2025-05-21 12:29:01 -04:00
Patrick Schleizer
2c1abb23e0
output 2025-05-21 12:26:46 -04:00
Patrick Schleizer
0801b96ae7
output 2025-05-21 12:25:49 -04:00
Patrick Schleizer
ef8515ba82
improve error handling 2025-05-21 12:23:45 -04:00
Patrick Schleizer
784867e24b
fix 2025-05-21 12:21:45 -04:00
Patrick Schleizer
e1bae1c68a
fix 2025-05-21 11:50:59 -04:00
Patrick Schleizer
14cf205579
fix 2025-05-21 08:36:16 -04:00
Patrick Schleizer
353b6e83c5
test that wc is functional
https://github.com/Kicksecure/security-misc/pull/305#issuecomment-2892378246
2025-05-21 07:20:13 -04:00
Patrick Schleizer
5930e27052
pam-info: improve error handling
https://github.com/Kicksecure/security-misc/pull/305#issuecomment-2892378246
2025-05-21 07:05:25 -04:00
Patrick Schleizer
5c981e0891
pam-info: fix, consistently write errors and warnings to stderr 2025-05-21 06:55:09 -04:00
Ashlen
e14b81b15e
perf(permission-hardener): optimize string match
Replace subprocess grep calls with bash substring matching in
check_nosuid_whitelist function. This eliminates ~10k unneeded
subprocess spawns that were causing significant performance
degradation.

In testing, it improves overall script execution speed by an
order of magnitude:

Before patch:
$ sudo hyperfine -- './permission-hardener enable'
Benchmark 1: ./permission-hardener enable
  Time (mean ± σ):     11.906 s ±  0.974 s    [User: 3.639 s, System: 8.728 s]
  Range (min … max):   10.430 s … 14.090 s    10 runs

After patch:
$ sudo hyperfine -- './permission-hardener enable'
Benchmark 1: ./permission-hardener enable
  Time (mean ± σ):     802.8 ms ± 178.5 ms    [User: 283.0 ms, System: 471.9 ms]
  Range (min … max):   639.4 ms … 1092.3 ms    10 runs
2025-05-20 21:34:03 -06:00
Ashlen
7a079c3de8
fix(permission-hardener): add exactwhitelist here
Without this, the permissions for ssh-agent won't be changed properly.
2025-05-20 18:41:48 -06:00
Ashlen
94dc9da4ab
fix(permission-hardener): ssh-agent gets 755 perms
Replace the commented-out matchwhitelist entry for ssh-agent with an
explicit permission entry (755) for /usr/bin/ssh-agent.

When ssh-agent's matchwhitelist entry was commented out in commit
7a5f8b87af, permission-hardener began resetting it to restrictive
defaults (744), preventing non-root users from executing ssh-agent. This
broke split SSH functionality in Qubes OS for me because I was using
Kicksecure in the vault qube, and ssh-agent runs under a non-root user in
that configuration (see https://forum.qubes-os.org/t/split-ssh/19060).

As noted in the comment, Debian installs with 2755 permissions as a way
to mitigate ptrace attacks, but this rationale doesn't apply due to
kernel.yama.ptrace_scope=2 being set in Kicksecure.
2025-05-20 18:04:46 -06:00
Patrick Schleizer
405880e63b
handle case of non-existence of /proc/cmdline 2025-05-18 06:44:42 -04:00
Patrick Schleizer
88235cc97b
refactoring 2025-05-18 06:44:04 -04:00
Patrick Schleizer
601ea77b00
end-of-options 2025-05-18 06:42:39 -04:00
Patrick Schleizer
d8feca1276
printf 2025-05-18 06:41:41 -04:00
Patrick Schleizer
7f2ba0980d
refactoring 2025-05-18 06:40:50 -04:00
DMHalford
91a76db66b
Prevent erroneous "Login blocked after [negative number] attempts" errors
For root, faillock appears to always* return an empty string (i.e. no table headers are present), yielding a zero-initialized pam_faillock_output_count and thus resulting in the calculation of a negative failed_login_counter value.

This can cause erroneous errors of the form "ERROR: Login blocked after [negative number] attempts" during sudo-ing and screen unlocking.

This commit modifies the initialization of failed_login_counter such that it cannot be negative and prevents the display of these incorrect warnings.

* Only rudimentary local tests were conducted
2025-05-15 15:42:50 -04:00
DMHalford
6c3be9ced0
Prevent erroneous "Login blocked after [negative number] attempts" errors
For root, faillock appears to always* return an empty string (i.e. no table headers are present), yielding a zero-initialized pam_faillock_output_count and thus resulting in the calculation of a negative failed_login_counter value.

This can cause erroneous errors of the form "ERROR: Login blocked after [negative number] attempts" during sudo-ing and screen unlocking.

This commit modifies the initialization of failed_login_counter such that it cannot be negative and prevents the display of these incorrect warnings.

* Only rudimentary tests were conducted
2025-05-15 15:06:10 -04:00
Patrick Schleizer
06e1e44b00
comments 2025-04-25 05:51:21 -04:00
Patrick Schleizer
a8f6132bec
output 2025-04-25 03:11:39 -04:00
Aaron Rainbolt
612f5f92fd
Fix umask for pkexec-run commands 2025-04-24 20:01:35 -05:00
Patrick Schleizer
9948ae114d
fix 2025-04-19 13:24:17 -04:00
Patrick Schleizer
4aca622706
fix 2025-04-19 13:23:26 -04:00
Patrick Schleizer
701f4a0e88
output 2025-04-19 13:20:04 -04:00
Patrick Schleizer
a670c0d873
comment 2025-04-19 13:18:23 -04:00
Patrick Schleizer
4799f3ce02
make /usr/libexec/security-misc/apt-get-update more reliable 2025-04-19 13:17:28 -04:00
Patrick Schleizer
c4f0e1d16f
refactoring 2025-04-19 12:57:14 -04:00
Patrick Schleizer
81634930fa
refactoring 2025-04-19 12:55:32 -04:00
Patrick Schleizer
90330a1ec9
refactoring 2025-04-19 12:49:18 -04:00
Patrick Schleizer
ce2c9a21a3
/usr/libexec/security-misc/apt-get-update: use /run/helper-scripts folder for pid file instead of $TMP
to avoid permission issues
2025-04-19 12:48:19 -04:00
Patrick Schleizer
96ff7c8dc6
refactoring 2025-04-19 12:45:06 -04:00
Patrick Schleizer
5a37790e6b
cleanup 2025-04-19 12:43:15 -04:00
Patrick Schleizer
9f2836d2ba
Merge pull request #304 from raja-grewal/stop_pstore
Disable PStore
2025-04-15 15:17:25 -04:00
Aaron Rainbolt
74ca63d12c
Mass-change "PERSISTENCE mode USERNAME" to "PERSISTENCE Mode - USERNAME Session" 2025-04-09 21:01:41 -05:00
Patrick Schleizer
39f4f5b607
comments 2025-04-08 06:53:08 -04:00
Patrick Schleizer
173606891a
output 2025-04-08 06:48:29 -04:00
raja-grewal
f643ebc2f9
Disable pstore processing by systemd-pstore service 2025-03-16 03:28:39 +00:00