-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(security): add behavioral session tracker with trifecta detection #965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gemini2026
wants to merge
5
commits into
NVIDIA:main
Choose a base branch
from
gemini2026:feat/session-tracker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0c275dd
feat(security): add behavioral session tracker with trifecta detection
gemini2026 a17e65d
fix(security): add empty sessionId guard and test for getExposure
gemini2026 7a8ee44
fix(security): deep-copy events in getExposure, fix docs accuracy
gemini2026 ce785dc
docs: shorten title.page to match H1 convention
gemini2026 282315f
docs: match H1 to title.page frontmatter value
gemini2026 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| --- | ||
| title: | ||
| page: "Session Tracker — Behavioral Trifecta Detection" | ||
| nav: "Session Tracker" | ||
| description: "Reference for the behavioral session tracker that detects multi-step exfiltration attacks by tracking three capability classes per agent session." | ||
| keywords: ["nemoclaw session tracker", "trifecta detection", "behavioral tracking", "exfiltration detection"] | ||
| topics: ["generative_ai", "ai_agents"] | ||
| tags: ["openclaw", "openshell", "security", "session", "trifecta"] | ||
| content: | ||
| type: reference | ||
| difficulty: intermediate | ||
| audience: ["developer", "engineer"] | ||
| status: published | ||
| --- | ||
|
|
||
| <!-- | ||
| SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| --> | ||
|
|
||
| # Session Tracker | ||
|
|
||
| The session tracker module detects multi-step exfiltration attacks by tracking three capability classes per agent session. | ||
|
|
||
| Per-action policy gates evaluate each tool call in isolation. | ||
| An agent that reads a secret, ingests untrusted input, and opens an outbound connection across separate actions can bypass per-action checks. | ||
| The session tracker aggregates these capabilities over the lifetime of a session and raises the risk level when the combination is dangerous. | ||
|
|
||
| ## Trifecta Detection | ||
|
|
||
| The tracker monitors three capability classes. | ||
|
|
||
| | Capability | Enum value | What it means | | ||
| |---|---|---| | ||
| | Read sensitive | `read_sensitive` | The agent accessed a sensitive file or secret | | ||
| | Ingested untrusted | `ingested_untrusted` | The agent consumed input from an external or untrusted source | | ||
| | Has egress | `has_egress` | The agent made or attempted an outbound network connection | | ||
|
|
||
| When all three capabilities appear in a single session, the session has a "trifecta." | ||
| A trifecta indicates a possible exfiltration chain: read a secret, get instructions from an attacker, and send the secret out. | ||
|
|
||
| ## Risk Levels | ||
|
|
||
| The tracker classifies each session into one of three risk levels. | ||
|
|
||
| | Level | Condition | | ||
| |---|---| | ||
| | `clean` | No capabilities recorded | | ||
| | `elevated` | One or two capabilities recorded | | ||
| | `critical` | All three capabilities recorded (trifecta) | | ||
|
|
||
| ## Event Storage | ||
|
|
||
| Each call to `record()` creates a `CapabilityEvent` with a capability, tool name, detail string, and timestamp. | ||
| The tracker stores up to 100 events per session. | ||
| Events beyond the 100th are dropped, but the capability set continues to update. | ||
|
|
||
| ## API | ||
|
|
||
| The module exports the following from `nemoclaw/src/security/session-tracker.ts`. | ||
|
|
||
| ### `SessionStore` | ||
|
|
||
| Class that tracks capability events per agent session. | ||
|
|
||
| ```typescript | ||
| import { SessionStore, Capability } from "./security/session-tracker.js"; | ||
|
|
||
| const store = new SessionStore(); | ||
| store.record("session-1", Capability.ReadSensitive, "cat", "/etc/passwd"); | ||
| store.record("session-1", Capability.HasEgress, "curl", "https://example.com"); | ||
| ``` | ||
|
|
||
| #### `record(sessionId: string, cap: Capability, tool: string, detail: string): void` | ||
|
|
||
| Record a capability event against a session. | ||
| Empty `sessionId` values are silently ignored. | ||
|
|
||
| #### `getCapabilities(sessionId: string): Record<string, boolean> | null` | ||
|
|
||
| Return the capability map for a session. | ||
| Returns `null` if the session does not exist or `sessionId` is empty. | ||
|
|
||
| #### `hasTrifecta(sessionId: string): boolean` | ||
|
|
||
| Return `true` if the session has all three capability classes. | ||
|
|
||
| #### `listSessions(): SessionSummary[]` | ||
|
|
||
| Return summaries of all active sessions. | ||
|
|
||
| #### `getExposure(sessionId: string): SessionExposure | null` | ||
|
|
||
| Return detailed exposure data for a session. | ||
| Returns `null` if the session does not exist or `sessionId` is empty. | ||
|
|
||
| The exposure object categorizes events into three lists. | ||
|
|
||
| - `sensitiveFilesAccessed` contains deduplicated file paths from `read_sensitive` events. | ||
| - `externalUrlsContacted` contains deduplicated URLs from `ingested_untrusted` events. | ||
| - `egressAttempts` contains every `has_egress` event as `tool` when `detail` is empty, or `tool + " " + detail` otherwise. | ||
| Egress attempts are not deduplicated. | ||
|
|
||
| ### `Capability` | ||
|
|
||
| Enum with three members. | ||
|
|
||
| ```typescript | ||
| enum Capability { | ||
| ReadSensitive = "read_sensitive", | ||
| IngestedUntrusted = "ingested_untrusted", | ||
| HasEgress = "has_egress", | ||
| } | ||
| ``` | ||
|
|
||
| ### `CapabilityEvent` | ||
|
|
||
| ```typescript | ||
| interface CapabilityEvent { | ||
| readonly capability: Capability; | ||
| readonly tool: string; | ||
| readonly detail: string; | ||
| readonly time: string; | ||
| } | ||
| ``` | ||
|
|
||
| ### `SessionSummary` | ||
|
|
||
| ```typescript | ||
| interface SessionSummary { | ||
| readonly sessionId: string; | ||
| readonly capabilities: Record<string, boolean>; | ||
| readonly trifecta: boolean; | ||
| readonly riskLevel: RiskLevel; | ||
| readonly eventCount: number; | ||
| } | ||
| ``` | ||
|
|
||
| ### `SessionExposure` | ||
|
|
||
| ```typescript | ||
| interface SessionExposure { | ||
| readonly sessionId: string; | ||
| readonly capabilities: Record<string, boolean>; | ||
| readonly trifecta: boolean; | ||
| readonly riskLevel: RiskLevel; | ||
| readonly events: readonly CapabilityEvent[]; | ||
| readonly sensitiveFilesAccessed: readonly string[]; | ||
| readonly externalUrlsContacted: readonly string[]; | ||
| readonly egressAttempts: readonly string[]; | ||
| } | ||
| ``` | ||
|
|
||
| ### `RiskLevel` | ||
|
|
||
| ```typescript | ||
| type RiskLevel = "clean" | "elevated" | "critical"; | ||
| ``` | ||
|
|
||
| ## Next Steps | ||
|
|
||
| - Review the injection scanner in {doc}`/reference/injection-scanner` to understand how NemoClaw detects prompt injection in agent tool calls. | ||
| - See the audit chain in {doc}`/reference/audit-chain` for tamper-evident logging of all policy decisions. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the H1 with
title.pagein frontmatter.The page-structure rule requires the H1 to match
title.page, but Line 21 (# Session Tracker) does not match Line 3 (Session Tracker — Behavioral Trifecta Detection).As per coding guidelines, "H1 heading matches the
title.pagefrontmatter value."Also applies to: 21-21
🤖 Prompt for AI Agents