agentleFS
janussonjanusson/MSMCP/skills/security-boundary/SKILL.md

security-boundary

Skill1 starsChanged 24 days agoMITView on GitHub

How every msmcp filesystem access must pass through the security boundary, and the error hierarchy that reports boundary violations.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this for any code path that resolves a user-supplied path or a resource limit.

    line 10
  2. Distinctive:

    Do not return a generic "analysis failed" string.

    line 56

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Security boundary

Use this for any code path that resolves a user-supplied path or a resource limit. Every tool that touches the local filesystem must pass its paths through msmcp.security. This includes acquisition files and spectral library files alike; a library is not exempt.

The three hard limits

Enforced by SecurityPolicy (src/msmcp/security.py):

LimitDefaultOverride
Allowed rootprocess working directoryMSMCP_ALLOWED_ROOT
Max file size500 MiBMSMCP_MAX_FILE_SIZE_BYTES
Max spectra per request1,000MSMCP_MAX_SPECTRA

DEFAULT_POLICY reads the environment once at import time. Build a custom policy with SecurityPolicy.from_env(**overrides) when a test or embedder needs different limits; break-glass precedence is overrides, then environment, then defaults.

Resolution rule

resolve_path makes the path absolute, expands ~, and resolves symlinks before the containment check. A symlink inside the root that points outside it is rejected, not followed. Never hand a raw user path to open().

Then call validate_file_size and validate_spectrum_count as appropriate.

Error hierarchy

Tools raise typed errors so the host can route the next step. Put a new error in the right place:

MsmcpError (errors.py)
├── InaccessiblePathError       # missing, not a file, no permission
├── MalformedFileError          # opened but does not parse
├── MissingDependencyError      # optional package absent
├── UnsupportedFormatError      # recognised but not supported
├── SpectrumIndexError          # no spectrum at the requested index
└── SecurityError (security.py)
    ├── PathEscapeError         # resolved outside the allowed root
    ├── FileSizeExceededError   # exceeds the byte limit
    └── SpectrumCountExceededError

Do not return a generic "analysis failed" string. The point of the hierarchy is that the why survives to the caller.

Resource limits beyond files

The server-side store (state/store.py, state/pointers.py) has its own bounds, enforced by refusing new registrations rather than evicting live data — a resource error must never become a wrong answer:

  • MSMCP_MAX_REFERENCES
  • MSMCP_MAX_TOTAL_BYTES
  • MSMCP_REFERENCE_TTL_SECONDS (default one hour)

A StoreLimitError is the expected outcome when a limit is hit.

Posture reminders

  • The server is offline and self-contained: no network, no credentials, no hosted service. open_world_hint=False on every tool.
  • There is no direct instrument control and no safety interlock layer in this repository, by design.

Tests

tests/test_security.py covers the boundary directly; tests/test_pointers.py covers the store limits. When adding a limit or an error, add a case that asserts the specific typed error, not just that something raised.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.