Rules

Baseline security rules and capability templates.


@securitylayerai/rules is a data package — YAML rule definitions and capability templates with a thin TypeScript loader. It has no runtime dependency on core. The CLI and other packages consume the YAML at runtime using core's parseRulesYaml().

Contents

Baseline rules (rules/baseline.yaml)

14 deterministic rules that complement core's built-in rules. These cover patterns that the built-in rules don't:

CategoryRule IDDecisionWhat it catches
Destructivedestructive-chmod-recursive-777DENYchmod -R 777 / (recursive world-writable on root)
Destructivedestructive-chown-recursiveDENYchown -R on system paths (/usr, /etc, /var, etc.)
Credentialscred-gnupgDENYAccess to ~/.gnupg/** (GnuPG keyring)
Credentialscred-pem-filesDENYcat, cp, scp etc. on .pem / .key files
Credentialscred-kube-configDENYAccess to ~/.kube/config
Credentialscred-docker-configDENYAccess to ~/.docker/config.json
Exfiltrationexfil-base64-to-curlDENYbase64 | curl pipe pattern
Exfiltrationexfil-tar-to-curlDENYtar | curl pipe pattern (archive to network)
RCErce-python-pipeDENYcurl | python pipe pattern
RCErce-eval-commandREQUIRE_APPROVALeval usage (may execute arbitrary code)
RCErce-netcat-listenerDENYnc -l (potential reverse shell)
Gitdangerous-git-force-pushDENYgit push --force to main/master
Packagesdangerous-npm-publishREQUIRE_APPROVALnpm publish
Containersdangerous-docker-privilegedDENYdocker run --privileged

Session templates (capabilities/sessions.yaml)

Pre-configured session capability sets:

TemplateCapabilitiesDefault taint
mainAll 15 capabilitiesowner
groupchannel.send, file.read, memory.read.trusted, web_fetchtrusted
dm-unknownchannel.send onlyuntrusted

Channel defaults (capabilities/channels.yaml)

Per-channel capability limits:

ChannelMax capabilities
owner-terminalALL
whatsappchannel.send, file.read, memory.read.trusted
telegramchannel.send, file.read, memory.read.trusted, web_fetch
slackchannel.send, file.read, web_fetch
discordchannel.send, file.read
emailchannel.send
webchatchannel.send, web_fetch

Skill defaults (capabilities/skills-defaults.yaml)

Common skill capability profiles:

ProfileCapabilities
read-onlyfile.read, web_fetch
file-editorfile.read, file.write
web-onlyweb_fetch
full-accessAll non-elevated capabilities

TypeScript API

import {
  getPackMetadata,
  loadBaselineRules,
  loadSessionTemplates,
  loadChannelDefaults,
  loadSkillDefaults,
} from "@securitylayerai/rules";

// Pack metadata
const meta = getPackMetadata();
// { name: "@securitylayerai/rules", version: "0.0.1", type: "rule-pack", ruleCount: 14 }

// Load baseline rules as raw YAML string
const rulesYaml = await loadBaselineRules();

// Load parsed capability templates
const sessions = await loadSessionTemplates();
const channels = await loadChannelDefaults();
const skills = await loadSkillDefaults();

Package structure

packages/rules/
├── src/
│   ├── index.ts          # Loader functions
│   └── types.ts          # RulePackMetadata, template types
├── rules/
│   └── baseline.yaml     # 14 security rules
├── capabilities/
│   ├── sessions.yaml     # Session templates
│   ├── channels.yaml     # Channel defaults
│   └── skills-defaults.yaml  # Skill profiles
└── test/
    └── loader.test.ts    # YAML loading + regex accuracy tests

Writing custom rules

The baseline rules are a starting point. You can add your own rules using the same YAML format:

version: 1
rules:
  - id: my-custom-rule
    description: Block access to production database
    match:
      type: pattern
      value: "\\bpsql\\s+.*production"
    decision: DENY
    reason: "Direct access to production database"

Rule match types:

  • pattern — Regex match against the full command string
  • path — Glob match against file paths
  • pipe_pair — Match piped command structures (fromto)

See also

On this page