This document defines the security model for running FScript programs with host externs.
- FScript executes in-process inside the host .NET application.
- Language-level side effects occur through registered externs.
- Host configuration determines the effective capability surface.
- Host context includes:
RootDirectory : stringDeniedPathGlobs : string list(glob patterns matched against root-relative paths)
- The CLI defaults
RootDirectoryto the script file directory in file mode (fscript script.fss). - In stdin and REPL modes (
cat script.fss | fscript,fscript), the CLI defaultsRootDirectoryto the current working directory. - The CLI allows overriding root with
--root <path>(or-r <path>). importfile resolution is constrained toRootDirectory.- Import paths are resolved relative to the current script file.
- Import cycles are rejected.
importis only available for file-based execution; stdin source mode rejectsimport.
Filesystem extern behavior:
Fs.readTextandFs.enumerateFilesresolve candidate paths throughHostCommon.tryResolvePath.Fs.exists,Fs.kind,Fs.createDirectory, andFs.writeTextuse the same root-confined resolution.Fs.globevaluates patterns underRootDirectory.- Access is granted for paths within
RootDirectory(or exactly equal to it). - Out-of-bound paths return
None/false/FsKind.Missingdepending on function shape. - Denied paths are matched by glob against root-relative paths.
- Examples:
.gitblocks only the root.gitsubtree,**/node_modulesblocks all nestednode_modulessubtrees. - Denied entries are hidden from
Fs.globandFs.enumerateFiles. - Read/write/mkdir operations on denied targets fail immediately with
EvalException.
- Extern invocation checks arity and argument type-shape.
- Data/IO externs frequently model operational failures as
Nonevalues. - Script type misuse raises
TypeException/EvalException.
- Evaluator execution currently relies on host/runtime process limits.
- CPU, memory, timeout, and cancellation governance are host-level concerns.
- Process/container isolation is a host deployment choice.
- Use least-privilege
RootDirectorysettings. - Register only required extern functions.
- Add host-level timeout/cancellation and resource limits for production.
- Monitor and audit extern usage, especially filesystem externs.
- Define exact input and output contracts.
- Validate and normalize host-side inputs and paths.
- Keep capability scope narrow.
- Model recoverable operational failures with
optionvalues. - Add tests for allow/deny paths and edge cases.