Documentation
¶
Overview ¶
Package windows owns the configuration and setup vocabulary for the Windows sandbox backends. Its public data types remain available on every platform.
Index ¶
- Variables
- func OpenRestrictedJournalAndSweep(stableScratchRoot string, cleaner RestrictedJournalCleaner) (*RestrictedJournal, RestrictedSweepReport, error)
- func Remove(context.Context, SetupConfig) error
- func Setup(context.Context, SetupConfig) error
- func ValidateConfig(config Config) error
- type ACERole
- type ACEType
- type ACLACE
- type ACLACEExpectation
- type ACLAccess
- type ACLLeaseID
- type ACLMutation
- type ACLObjectIdentity
- type ACLObjectKind
- type ACLPlan
- type ACLPlanEntry
- type ACLPlanRequest
- type ACLRollbackMetadata
- type ACLScope
- type ACLValidationTarget
- type Config
- type OneShotSIDGenerator
- type RestrictedCleanupRecord
- type RestrictedJournal
- func (j *RestrictedJournal) Close() error
- func (j *RestrictedJournal) CompleteCleanup(key string) error
- func (j *RestrictedJournal) PrepareMutation(record RestrictedCleanupRecord) (string, error)
- func (j *RestrictedJournal) Prune(pruner RestrictedPruner) error
- func (j *RestrictedJournal) RetireSID(sid SID) (bool, error)
- func (j *RestrictedJournal) Sweep(cleaner RestrictedJournalCleaner) (RestrictedSweepReport, error)
- type RestrictedJournalCleaner
- type RestrictedPruner
- type RestrictedRuntime
- type RestrictedSweepReport
- type SID
- type SIDRetirementStore
- type SandboxMode
- type SetupConfig
- type SetupProblem
- type SetupStatus
- type WindowsSetupProblemCode
Constants ¶
This section is empty.
Variables ¶
var ( ErrSetupRequired error = unavailableError("sandbox: Windows elevated setup required") ErrSetupStale error = unavailableError("sandbox: Windows elevated setup is stale") ErrElevationRequired = errors.New("sandbox: Windows setup requires elevation") )
var ( // ErrJobCompletionWait marks a failure to prove that a terminated Job has // reached zero active processes. Callers must escalate containment rather // than treating this as successful cleanup. ErrJobCompletionWait = errors.New("sandbox: Windows Job completion wait failed") )
var ErrRestrictedTargetChanged = errors.New("sandbox: restricted cleanup target changed")
ErrRestrictedTargetChanged means cleanup found a different filesystem object at the recorded path. The journal must never use a path alone as authority.
var ErrSIDReuse = errors.New("sandbox: one-shot Windows SID entropy reused")
Functions ¶
func OpenRestrictedJournalAndSweep ¶
func OpenRestrictedJournalAndSweep(stableScratchRoot string, cleaner RestrictedJournalCleaner) (*RestrictedJournal, RestrictedSweepReport, error)
OpenRestrictedJournalAndSweep is the construction path used by the backend: recovery runs before a fresh restricted SID or ACL lease is created.
func ValidateConfig ¶
ValidateConfig rejects Windows-only executor settings on non-Windows hosts.
Types ¶
type ACLACEExpectation ¶
ACLACEExpectation describes an ACE that read-back must find logically. An inherited ACE's raw header is produced by Windows, so it is matched by role, SID, access, and inheritance rather than by pretending its bytes are stable.
type ACLLeaseID ¶
type ACLLeaseID [16]byte
type ACLMutation ¶
type ACLMutation struct {
// contains filtered or unexported fields
}
func (ACLMutation) ACE ¶
func (mutation ACLMutation) ACE() ACLACE
func (ACLMutation) Object ¶
func (mutation ACLMutation) Object() ACLObjectIdentity
func (ACLMutation) Rollback ¶
func (mutation ACLMutation) Rollback() ACLRollbackMetadata
type ACLObjectIdentity ¶
type ACLObjectIdentity struct {
VolumeSerial uint64
FileID [16]byte
Kind ACLObjectKind
ReparseTag uint32
LinkCount uint32
}
ACLObjectIdentity is the complete identity required to verify an object again immediately before mutation. A path string is deliberately absent.
type ACLObjectKind ¶
type ACLObjectKind uint8
const ( ACLObjectUnknown ACLObjectKind = iota ACLObjectFile ACLObjectDirectory ACLObjectReparsePoint )
type ACLPlan ¶
type ACLPlan struct {
// contains filtered or unexported fields
}
ACLPlan is immutable after construction. Every slice-returning accessor returns a defensive copy so journal/apply code cannot accidentally alter it.
func BuildACLPlan ¶
func BuildACLPlan(request ACLPlanRequest) (ACLPlan, error)
func (ACLPlan) Mutations ¶
func (plan ACLPlan) Mutations() []ACLMutation
func (ACLPlan) Narrowings ¶
func (ACLPlan) RootIdentity ¶
func (plan ACLPlan) RootIdentity() ACLObjectIdentity
RootIdentity returns the root object encoded by this plan.
func (ACLPlan) SkippedReparsePoints ¶
func (plan ACLPlan) SkippedReparsePoints() []ACLObjectIdentity
func (ACLPlan) ValidationTargets ¶
func (plan ACLPlan) ValidationTargets() []ACLValidationTarget
ValidationTargets retains every ordinary identity enumerated for the plan, even when it needs no explicit mutation. Task 10 pairs each target with its retained OS handle by complete identity and verifies inherited propagation.
type ACLPlanEntry ¶
type ACLPlanEntry struct {
Object ACLObjectIdentity
Deny ACLAccess
}
type ACLPlanRequest ¶
type ACLPlanRequest struct {
LeaseID ACLLeaseID
SID SID
Scope ACLScope
Access ACLAccess
Root ACLObjectIdentity
Entries []ACLPlanEntry
}
ACLPlanRequest consumes an already no-follow-enumerated object set. Planning performs no filesystem traversal and skips every reparse entry.
type ACLRollbackMetadata ¶
type ACLRollbackMetadata struct {
LeaseID ACLLeaseID
Role ACERole
SID SID
ACEHash [sha256.Size]byte
}
ACLRollbackMetadata identifies one lease-owned ACE without assuming it was absent before apply. Task 10 must capture the baseline occurrence count of identical ACE bytes atomically with read/apply; rollback removes only the lease's added occurrence above that baseline.
type ACLValidationTarget ¶
type ACLValidationTarget struct {
Object ACLObjectIdentity
Required []ACLACEExpectation
}
type Config ¶
type Config struct {
Mode SandboxMode
StateRoot string
}
Config contains the Windows backend settings attached to an executor set.
type OneShotSIDGenerator ¶
type OneShotSIDGenerator struct {
// contains filtered or unexported fields
}
OneShotSIDGenerator creates grant SIDs from injected cryptographic entropy. Never-reuse authority belongs to the injected atomic retirement store, not this process, so separate generators and process restarts cannot race reuse.
func NewOneShotSIDGenerator ¶
func NewOneShotSIDGenerator(source io.Reader, store SIDRetirementStore) (*OneShotSIDGenerator, error)
func (*OneShotSIDGenerator) Next ¶
func (generator *OneShotSIDGenerator) Next() (SID, error)
type RestrictedCleanupRecord ¶
type RestrictedCleanupRecord struct {
Path string
Object ACLObjectIdentity
Rollback ACLRollbackMetadata
ACE []byte
BaselineOccurrences uint32
}
RestrictedCleanupRecord is cleanup authority, never access authority. An ACL implementation may use it only to remove the exact lease-owned occurrence above BaselineOccurrences after revalidating Object on a retained handle.
type RestrictedJournal ¶
type RestrictedJournal struct {
// contains filtered or unexported fields
}
RestrictedJournal is rooted outside any executor-owned temporary subtree. Separate instances coordinate through create-exclusive files; no in-memory check-then-write is used for SID retirement.
func OpenRestrictedJournal ¶
func OpenRestrictedJournal(stableScratchRoot string) (*RestrictedJournal, error)
OpenRestrictedJournal creates the durable store below stableScratchRoot. Construction is deliberately separate from Sweep so callers control the handle-bound cleanup implementation and can report retained cleanup loss.
func (*RestrictedJournal) Close ¶
func (j *RestrictedJournal) Close() error
Close releases the retained directory handles. It is safe to call more than once and waits for in-flight journal operations to finish.
func (*RestrictedJournal) CompleteCleanup ¶
func (j *RestrictedJournal) CompleteCleanup(key string) error
CompleteCleanup removes a cleanup record only after its exact ACE is known absent. A missing record is tolerated because the untrusted child may delete journal data; the corresponding SID remains permanently retired.
func (*RestrictedJournal) PrepareMutation ¶
func (j *RestrictedJournal) PrepareMutation(record RestrictedCleanupRecord) (string, error)
PrepareMutation durably records cleanup before a caller changes a DACL. The returned opaque key is passed to CompleteCleanup only after read-back proves the recorded ACE absent.
func (*RestrictedJournal) Prune ¶
func (j *RestrictedJournal) Prune(pruner RestrictedPruner) error
Prune asks a safe enumerator to remove only exact restricting allows for SIDs durably retired by this store. Denies are intentionally excluded because the caller-writable retirement store cannot prove that removing one is harmless.
func (*RestrictedJournal) RetireSID ¶
func (j *RestrictedJournal) RetireSID(sid SID) (bool, error)
RetireSID atomically and durably records a transient executor or one-shot SID before issuance. Installation SIDs are persistent names and are never valid restricted-tier cleanup capabilities.
func (*RestrictedJournal) Sweep ¶
func (j *RestrictedJournal) Sweep(cleaner RestrictedJournalCleaner) (RestrictedSweepReport, error)
Sweep attempts cleanup for every valid record. Corrupt or concurrently deleted records are tolerated as cleanup loss. A target mismatch or a false cleaner result retains the record and cannot authorize any access.
type RestrictedJournalCleaner ¶
type RestrictedJournalCleaner interface {
RemoveRestrictedAllowACE(RestrictedCleanupRecord) (removed bool, err error)
}
RestrictedJournalCleaner is the handle-bound half of crash recovery. Sweep deliberately supplies restricting allows only: removing one can only narrow access, even when every byte of the caller-writable journal was forged. Deny cleanup requires live, independently trusted lease state and is never authorized by this journal. The implementation must re-open without following links, compare the complete object identity, and remove only the recorded ACE occurrence. A false result retains the record. Cleaners may call other journal operations, but must not call Close from the callback.
type RestrictedPruner ¶
RestrictedPruner may opportunistically remove exact allow ACEs for retired SIDs while it performs an independently safe, handle-bound tree enumeration. Journal data is supplied only as removal authority. Pruners may call other journal operations, but must not call Close while PruneRestrictedACEs is active because Close deliberately waits for the callback to return.
type RestrictedRuntime ¶
type RestrictedRuntime struct {
// contains filtered or unexported fields
}
RestrictedRuntime coordinates crash-recovery state for every restricted backend owned by one ExecutorSet. Construction is side-effect free; the platform implementation opens and sweeps its journal lazily at most once.
func AcquireRestrictedRuntime ¶
func AcquireRestrictedRuntime(scratchRoot string) (*RestrictedRuntime, func() error)
AcquireRestrictedRuntime is a side-effect-free portability stub. Non-Windows platform selection rejects Windows mechanisms before the runtime is used.
func NewRestrictedRuntime ¶
func NewRestrictedRuntime(scratchRoot string) *RestrictedRuntime
NewRestrictedRuntime constructs one unregistered coordinator, primarily for focused package tests. ExecutorSet construction uses AcquireRestrictedRuntime so concurrent same-root sets share a live coordinator.
func (*RestrictedRuntime) Close ¶
func (runtime *RestrictedRuntime) Close() error
Close releases journal handles owned by a directly constructed runtime. ExecutorSet callers normally use the idempotent release returned by AcquireRestrictedRuntime instead.
type RestrictedSweepReport ¶
type SID ¶
type SID struct {
// contains filtered or unexported fields
}
SID is a module-issued private Windows trustee SID. Its representation and role are intentionally closed so callers cannot convert arbitrary text into a principal accepted by the token or ACL boundary.
func ExecutorSID ¶
ExecutorSID deterministically names one executor within an installation.
func InstallationSID ¶
InstallationSID deterministically names installation-owned runtime objects.
type SIDRetirementStore ¶
SIDRetirementStore atomically retires a SID before it is issued. It returns true only for the first retirement. Task 10 provides the durable journal- backed implementation; callers must never implement this as check-then-put.
type SandboxMode ¶
type SandboxMode uint8
SandboxMode selects the Windows confinement tier.
const ( Auto SandboxMode = iota RestrictedToken Elevated )
type SetupConfig ¶
type SetupConfig struct {
InstallationID string
StateRoot string
HostBinary string
// RuntimeEvidencePath names the reviewed Task 5 evidence artifact to
// import into the protected installation. Setup never treats an
// environment variable or a boolean flag as runtime approval.
RuntimeEvidencePath string
ProxyPorts []uint16
}
SetupConfig identifies one elevated Windows sandbox installation.
type SetupProblem ¶
type SetupProblem struct {
Code WindowsSetupProblemCode
Resource string
Path string
Port uint16
PID uint32
Detail string
}
SetupProblem describes one problem found while inspecting setup state. Detail is diagnostic text, not a stable API.
type SetupStatus ¶
type SetupStatus struct {
Ready bool
Version uint32
InstallationID string
OwnerSID string
OfflineAccount string
OnlineAccount string
ProxyPorts []uint16
Problems []SetupProblem
}
SetupStatus reports the inspected state of one Windows installation.
func Inspect ¶
func Inspect(context.Context, SetupConfig) (SetupStatus, error)
type WindowsSetupProblemCode ¶
type WindowsSetupProblemCode uint16
WindowsSetupProblemCode identifies one stable setup inspection problem.
const ( SetupProblemUnknown WindowsSetupProblemCode = iota SetupProblemManifestMissing SetupProblemOwnerMismatch SetupProblemHostBinaryStale SetupProblemAccountMissing SetupProblemFirewallOverridden SetupProblemFirewallRuleChanged SetupProblemPortInUse SetupProblemRuntimeBaselineGap SetupProblemLeaseRecoveryPending SetupProblemProtocolMismatch )