Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- **Embedded and preload sandbox policies now intersect.** An allowing
in-process checker no longer bypasses a stricter shared-memory or file grant
list; an operation must satisfy every active containment layer.
11 changes: 6 additions & 5 deletions runtime/libaether_sandbox_preload.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions tests/integration/sandbox_policy_intersection/harness.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/sh
# When both the embedded checker and preload grants are active, an operation
# must satisfy both policies. Neither policy may replace the other.

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
LIB="$ROOT/build/libaether_sandbox.so"

case "$(uname -s 2>/dev/null)" in
Linux|FreeBSD) ;;
*)
echo " [SKIP] sandbox_policy_intersection: preload is Linux and FreeBSD only"
exit 0 ;;
esac
if [ ! -f "$LIB" ]; then
echo " [SKIP] sandbox_policy_intersection: preload library not built"
exit 0
fi

TMP="$(cd "$(mktemp -d)" && pwd -P)"
trap 'rm -rf "$TMP"' EXIT
if ! ${CC:-cc} -std=c11 -Wall -Wextra -Werror -rdynamic \
"$SCRIPT_DIR/harness.c" -o "$TMP/harness"; then
echo " [FAIL] sandbox_policy_intersection: harness did not compile"
exit 1
fi

printf 'intersection sentinel\n' > "$TMP/data.txt"
printf 'exec:/not-used\n' > "$TMP/deny-read.grants"
printf 'fs_read:%s\n' "$TMP/data.txt" > "$TMP/allow-read.grants"
fail=0

run_case() {
label="$1"
checker="$2"
grants="$3"
expected="$4"
if LD_PRELOAD="$LIB" AETHER_SANDBOX_GRANTS="$grants" \
AETHER_SANDBOX_LOG=none "$TMP/harness" "$checker" "$TMP/data.txt" \
>"$TMP/out" 2>"$TMP/err"; then
got=allow
else
got=deny
fi
if [ "$got" = "$expected" ]; then
echo " [PASS] $label"
else
echo " [FAIL] $label: got $got, expected $expected"
fail=1
fi
}

run_case "preload denial survives an allowing embedded checker" \
allow "$TMP/deny-read.grants" deny
run_case "embedded denial survives an allowing preload policy" \
deny "$TMP/allow-read.grants" deny
run_case "both policies allowing permits the read" \
allow "$TMP/allow-read.grants" allow

echo ""
echo "sandbox_policy_intersection: $([ "$fail" -eq 0 ] && echo PASS || echo FAIL)"
[ "$fail" -eq 0 ]
Loading