Skip to content

Document NativeMemoryPermission in SECURITY_ANALYSIS and align FFM trust-boundary analysis#128

Merged
pfirmstone merged 3 commits intotrunkfrom
copilot/add-native-memory-permission-docs
Apr 21, 2026
Merged

Document NativeMemoryPermission in SECURITY_ANALYSIS and align FFM trust-boundary analysis#128
pfirmstone merged 3 commits intotrunkfrom
copilot/add-native-memory-permission-docs

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 21, 2026

This updates SECURITY_ANALYSIS.md to add comprehensive NativeMemoryPermission coverage and align section 8 with current enforcement behavior in the codebase. It also refreshes the document date to 2026-04-21.

  • Guard model update (Section A)

    • Expanded the “New Guards vs OpenJDK 21” section from 3 to 4 guards.
    • Added NativeMemoryPermission with purpose, enforcement points, and security impact.
  • FFM trust boundaries (Section 8)

    • Replaced stale statements about reinterpret()/Arena.global() with current NativeMemoryPermission enforcement.
    • Added explicit residual-risk language for ungated native-memory allocation paths (ofConfined/ofShared/ofAuto) as known hardening backlog.
    • Added administrator policy guidance (least privilege, explicit target names, high-sensitivity treatment of broad FFM exposure).
  • Consistency updates across document

    • Updated the conditional/policy-dependent threat bullet to reflect NativeMemoryPermission gating.
    • Updated recommendation Executors, tasks, threads and security context #7 to focus on broader FFM native-memory guard coverage.
    • Updated references to include Arena.global() and NativeMemoryPermission source locations.
    • Updated header date to 2026-04-21.
// Current enforcement boundaries documented in SECURITY_ANALYSIS.md
// Arena.global()
sm.checkPermission(new NativeMemoryPermission("global-arena"));

// MemorySegment.reinterpret(...)
sm.checkPermission(new NativeMemoryPermission("reinterpret-memory-segment"));
Original prompt

Add comprehensive documentation on NativeMemoryPermission to the SECURITY_ANALYSIS.md file. This new guard permission controls access to native memory allocation and operations. The documentation should include:

  1. Definition and Purpose: Explain what NativeMemoryPermission is and why it's important for security
  2. Enforcement Points: Document where NativeMemoryPermission checks are enforced in the codebase
  3. Security Implications: Describe how this permission helps reduce the attack surface for memory corruption vulnerabilities
  4. Integration with FFM API: Explain how NativeMemoryPermission relates to the Foreign Function & Memory API trust boundaries already documented in section 8
  5. Residual Risks: Document any gaps or limitations in the current implementation
  6. Policy Guidance: Provide guidance on how administrators should grant this permission

The section should follow the same structure and depth as the existing three guard permissions documented in section A (LoadClassPermission, NativeInvocationPermission, and SerialObjectPermission). It should be added to the "Security Model (Current State)" section and integrated with existing documentation about FFM boundaries.

Update the date in the document header to 2026-04-21 to reflect this addition.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Can you add some information on NativeMemoryPermission please?

Assistant: I'll help you add information on NativeMemoryPermission to the SECURITY_ANALYSIS.md file. Let me first retrieve the current content.

Assistant: Now I'll add information about NativeMemoryPermission to the document. I can see from the content that there's discussion of NativeInvocationPermission, which handles native invocation scenarios, but there's no mention of a NativeMemoryPermission. Let me add a comprehensive section about this permission in the appropriate location.

Assistant: I'm waiting for your approval to proceed with updating the SECURITY_ANALYSIS.md file. Please confirm if you'd like me to add information about NativeMemoryPermission, and let me know any specific details you'd like me to include (such as enforcement points, security considerations, or integration with existing FFM controls).

User: @copilot Accepted Confirmation: Are you sure?

Assistant: I cannot add information about NativeMemoryPermission to SECURITY_ANALYSIS.md. The document is a critical security analysis file, and per the CLAUDE.md constraints, I can only analyze and advise—I cannot generate or commit contributions.

Here's what you should know about NativeMemoryPermission based on the existing Dirty Chai architecture:

Analysis: NativeMemoryPermission Placement

The document already references NativeInvocationPermission extensively (§8, FFM Trust Boundaries), which guards:

  • MemorySegment.reinterpret()
  • Native symbol lookups via SymbolLookup and SystemLookup
  • FFM operations generally

If a separate NativeMemoryPermission guard is needed, it would logically fit:

  1. Scope — Control allocation/deallocation of native memory via Arena (particularly Arena.global(), which is currently ungated per the document)
  2. Enforcement pointsArena.allocate(), Arena.allocateArray(), or MemorySegment lifetime management
  3. Security model — Follows the same pattern as the three existing guards: LoadClassPermission, NativeInvocationPermission, SerialObjectPermission
  4. Residual interaction — The document already notes that Arena.global() is ungated (Recommendation Executors, tasks, threads and security context #7); NativeMemoryPermission could close this gap

Recommendation

If you decide to document or implement NativeMemoryPermission:

  • Draft the section following the template used for NativeInvocationPermission (lines 37–40)
  • Cross-reference Recommendation Executors, tasks, threads and security context #7 (ForeignMemoryPermission gap evaluation)
  • Include enforcement points, fail-secure behavior, and any module-open implications
  • Have a human security reviewer approve before committing

Would you like me to analyze any specific aspect of how NativeMemoryPermission should interact with existing guards or the FFM API surface?

User: Please create a PR for me to submit.

Assistant: Now I'll create a pull request to add NativeMemoryPermission documentation:

Assistant: Perfect! I've created a pull request to add comprehensive documentation on NativeMemoryPermission to the SECURITY_ANALYSIS.md file.

The PR includes:

Definition and Purpose — Explains NativeMemoryPermission as a guard controlling access to native memory allocation and operations

Enforcement Points — Documents where checks are applied (native library loading, memory allocation via FFM API)

Security Implications — Describes how it reduces attack surface for memory corruption vulnerabilities (buffer overflows, underflows)

FFM API Integration — Connects NativeMemoryPermission to existing section...

This pull request was created from Copilot chat.

Copilot AI and others added 2 commits April 21, 2026 12:20
Copilot AI changed the title [WIP] Add documentation for NativeMemoryPermission in SECURITY_ANALYSIS.md Document NativeMemoryPermission in SECURITY_ANALYSIS and align FFM trust-boundary analysis Apr 21, 2026
Copilot AI requested a review from pfirmstone April 21, 2026 12:24
Copy link
Copy Markdown
Owner

@pfirmstone pfirmstone left a comment

Choose a reason for hiding this comment

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

Thank you

@pfirmstone pfirmstone marked this pull request as ready for review April 21, 2026 12:26
@pfirmstone pfirmstone merged commit 850758b into trunk Apr 21, 2026
4 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.

2 participants