sipeed/picoclaw · error

set token low integrity: %w

Error message

set token low integrity: %w

What it means

Raised in setTokenLowIntegrity when windows.SetTokenInformation(token, TokenIntegrityLevel, &tml, tml.Size()) fails while lowering the duplicated token's integrity to Low. The Tokenmandatorylabel struct carries the low SID with SE_GROUP_INTEGRITY. Failure means Windows refused to apply the integrity label to the restricted token that will be assigned to the child.

Source

Thrown at pkg/isolation/platform_windows.go:205

// integrity locations are blocked by the OS.
func setTokenLowIntegrity(token windows.Token) error {
	lowSID, err := windows.CreateWellKnownSid(windows.WinLowLabelSid)
	if err != nil {
		return fmt.Errorf("create low integrity sid: %w", err)
	}
	tml := windows.Tokenmandatorylabel{
		Label: windows.SIDAndAttributes{
			Sid:        lowSID,
			Attributes: windows.SE_GROUP_INTEGRITY,
		},
	}
	if err := windows.SetTokenInformation(
		token,
		windows.TokenIntegrityLevel,
		(*byte)(unsafe.Pointer(&tml)),
		tml.Size(),
	); err != nil {
		return fmt.Errorf("set token low integrity: %w", err)
	}
	return nil
}

// formatWindowsAccessRules reshapes the internal rules for structured logging.
func formatWindowsAccessRules(rules []AccessRule) []map[string]string {
	formatted := make([]map[string]string, 0, len(rules))
	for _, rule := range rules {
		formatted = append(formatted, map[string]string{
			"path": rule.Path,
			"mode": rule.Mode,
		})
	}
	return formatted
}

View on GitHub (pinned to 49183d7e8d)

Solutions

  1. Unwrap the errno: ERROR_ACCESS_DENIED (5) means the token cannot be adjusted — check whether security software or group policy restricts SetTokenInformation
  2. Confirm the parent process token is a normal user token (not already restricted/sandboxed) before enabling isolation
  3. Add an exclusion for the process in the interfering EDR/AV, or disable isolation on that host
  4. Verify the Windows image is genuine (sfc /scannow) if no policy explains the denial
Defensive patterns

Strategy: try-catch

Try / catch

if err := launchIsolated(cmd); err != nil {
    if strings.Contains(err.Error(), "set token low integrity") {
        var errno syscall.Errno
        if errors.As(err, &errno) && errno == windows.ERROR_ACCESS_DENIED {
            // token adjustment blocked by policy/EDR: refuse unconfined execution
            return fmt.Errorf("host policy blocks integrity changes (errno %d); disable isolation on this host", errno)
        }
    }
    return err
}

Prevention

When it happens

Trigger: (1) The token handle lacks TOKEN_ADJUST_DEFAULT rights (the earlier OpenProcessToken/DuplicateTokenEx requested them, so this points at policy or handle tampering); (2) ERROR_INVALID_PARAMETER from a malformed label/size — not expected from this code path; (3) attempting to raise rather than lower integrity without privileges (not this path, which only lowers); (4) EDR/LSASS policy stripping label-modification rights from duplicated tokens.

Common situations: Hardened hosts or application-control software (CrowdStrike, AppLocker policies) that restrict token manipulation; running the parent under a heavily restricted service account whose token duplication drops adjust rights; broken Windows security baseline GPOs on the host.

Related errors


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/383936838edcb10c. Report an issue: GitHub.