Skip to content

Reject non-native ABIs in ML seccomp BPF filter#3080

Draft
edsavage wants to merge 3 commits into
elastic:mainfrom
edsavage:security/seccomp-arch-check
Draft

Reject non-native ABIs in ML seccomp BPF filter#3080
edsavage wants to merge 3 commits into
elastic:mainfrom
edsavage:security/seccomp-arch-check

Conversation

@edsavage

Copy link
Copy Markdown
Contributor

Summary

Follow-up to elastic/security#12621 (HackerOne): the Linux CSystemCallFilter matched only on seccomp_data.nr, so an x86_64 process could issue int 0x80 (i386) and hit syscall-number collisions — notably i386 socketcall (102) vs allowlisted x86_64 getuid (102). That opened a socket surface the policy intended to block, enabling later HotSpot Attach / JVM escalation in the reported chain.

Fix

Require seccomp_data.arch to match the native ABI (AUDIT_ARCH_X86_64 / AUDIT_ARCH_AARCH64) before any nr allowlist matching. Mismatch returns EACCES immediately. The arch check is a self-contained prefix so existing relative jump offsets in the nr allowlist are unchanged.

Test plan

  • Linux CI: existing CSystemCallFilterTest still passes (allowlisted ops work; std::system blocked).
  • Manual / security review: confirm i386 int 0x80 syscalls are denied under the new filter (compat-ABI path not covered by unit tests).

Related: #3078 (__setstate__ pre-load), forthcoming controller PR_SET_DUMPABLE PR.

Made with Cursor

The Linux seccomp filter matched only on seccomp_data.nr, so an x86_64
process could issue int 0x80 (i386) and hit number collisions — notably
i386 socketcall (102) vs allowlisted x86_64 getuid (102). That opened a
socket surface the policy intended to block (elastic/security#12621).

Require seccomp_data.arch to match the native ABI (AUDIT_ARCH_X86_64 /
AUDIT_ARCH_AARCH64) with an immediate deny on mismatch, before any nr
allowlist matching. The arch check is self-contained so existing relative
jump offsets in the nr allowlist are unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the Linux seccomp-BPF syscall filter used by ML processes by rejecting non-native/compat ABIs via seccomp_data.arch before any syscall-number allowlist checks, preventing syscall-number collisions (e.g. i386 socketcall vs x86_64 getuid).

Changes:

  • Add an ABI/arch gate at the start of the Linux seccomp BPF program (x86_64/aarch64).
  • Update public header documentation to describe the new seccomp_data.arch requirement.
  • Add a changelog entry and clarify unit-test intent/limitations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
lib/seccomp/CSystemCallFilter_Linux.cc Adds seccomp_data.arch check prefix to deny foreign/compat ABIs before syscall allowlist matching.
lib/seccomp/unittest/CSystemCallFilterTest.cc Documents that the compat-ABI path isn’t currently exercised by the unit test.
include/seccomp/CSystemCallFilter.h Documents the new native-ABI requirement for the Linux filter.
docs/changelog/3080.yaml Adds changelog entry for the security hardening.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/seccomp/CSystemCallFilter_Linux.cc Outdated
Comment thread lib/seccomp/unittest/CSystemCallFilterTest.cc Outdated
Use offsetof for seccomp_data field loads and add an x86_64-only
int 0x80 denial test, soft-skipped when IA32 emulation is unavailable.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment on lines +201 to +203
// NOLINTNEXTLINE(hicpp-no-assembler)
asm volatile("int $0x80" : "=a"(ret) : "a"(nr) : "memory");
result = ret;
Comment on lines +214 to +216
// NOLINTNEXTLINE(hicpp-no-assembler)
asm volatile("int $0x80" : "=a"(ret) : "a"(nr) : "memory");
return ret;
Comment on lines 38 to 39
//! macOs:
//! The sandbox facility is used to restict access to system resources.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants