﻿# Why does a noexec staging mount not prohibit Python imports?

A practical investigation of why does a noexec staging mount not prohibit Python imports?, with explicit observations, control cases and evidence limits.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/field-security-noexec-does-not-block-interpreter-imports/
Language: en

## The operational scenario

An adapter-upload directory is mounted noexec, and the deployment record calls all uploaded content non-executable. The worker still has a Python interpreter and can read files there. If application logic imports or interprets an uploaded source file, the mount label has not established the claimed boundary. The issue is a mismatch between direct program execution and source consumed as data by another executable.

## The trust-boundary mechanism

The Linux mount reference defines noexec in terms of direct execution on the mounted filesystem, and execve documents the corresponding permission failure. Python’s import machinery separately loads and executes module code through an already running interpreter. Preventing an execve of a file does not remove ordinary read permission or validate what the application does with the bytes it reads.

## Define the control contract

Define which uploaded formats are data, which trusted components may interpret them and which directories can supply application code. Keep accepted adapter data outside plugin search paths and explicit dynamic-source loading routes. Preserve mount options as one layer rather than labeling them a complete code-execution policy. Native library loading and other interpreter mechanisms require their own supported behavior checks, not assumptions copied from pure Python source.

## A step-by-step verification

First inspect effective mounts from the worker’s namespace. In a disposable fixture, compare a harmless direct-execution attempt with a permitted interpreter reading a harmless marker source. Verify the actual intended distinction without exposing an upload endpoint. Then check that production application routing never treats adapter files as plugins or arbitrary source, and that trusted code paths and accepted data paths remain separately controlled.

## Evidence required for acceptance

Evidence should retain mount identity and flags, process identity, access rules and observed results for each distinct operation. A control must reject the claim that one denied direct execution proves every interpreter import impossible. Also test a valid adapter-loading scenario under the intended restrictions, so removing an accidental code path does not silently break the declared data workflow. Keep fixture actions and expected outcomes explicit.

## Failure cases and limits

Noexec remains a useful constraint within its documented scope. The conclusion is not that mount restrictions have no value, but that they do not supply every requested guarantee. This protocol executes no uploaded code and does not establish complete sandbox isolation. It separates direct execution, readable data and application-controlled interpretation so an accepted adapter package cannot acquire unsupported trust from one mount option.

## Primary references and related reading

Noexec constrains direct execution from a mount; readable source consumed by an allowed interpreter needs another boundary. [Linux mount noexec boundary](https://man7.org/linux/man-pages/man8/mount.8.html); [Linux execve program execution](https://man7.org/linux/man-pages/man2/execve.2.html); [Python import and source loading](https://docs.python.org/3/library/importlib.html).

The proposed investigation of noexec does not block interpreter imports is a proposed control review; no live security test was executed. Related reading: [Read-only container will not start: where to allow temporary and cache writes](/journal/read-only-container-writable-caches/); [Pin and review custom model code before enabling trust_remote_code](/journal/huggingface-remote-code-review/).
