Skip to content

Security review only (do not merge): #532 Lookout event-pattern filters on outside sources - #580

Closed
lydakis wants to merge 1 commit into
security-review/532-basefrom
security-review/532
Closed

lydakis wants to merge 1 commit into
security-review/532-basefrom
security-review/532

Conversation

@lydakis

@lydakis lydakis commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Do not merge. This PR exists only so Codex runs the security review that #532 never got (tracked in #531). The base is the commit before #532 merged (a760de7^) and the head is the merge commit a760de7, so the diff is exactly what #532 landed on main. Once findings are fixed on main or filed, this PR gets closed and both security-review/532* branches are deleted.

What to look at: a new pattern matcher runs over events from outside sources, and those events then reach agents' tool-enabled turns (#348). The source code also grew. Check for parser abuse (size and depth), injection into the notes agents read, and leaks between subscriptions.

…tern; agents see each source's shape (#532)

* Lookout: a subscription filters its sources' events with an event pattern; sources keep their fields and the lookout keeps each source's shape

A source's event keeps every field its line printed, and a subscription's
filter (an EventBridge-style event pattern: prefix, suffix, wildcard,
equals-ignore-case, anything-but, numeric, exists, $or) hears only the
events it matches, checked as each event comes. The lookout keeps each
source's shape (recent fields, kinds, an example) beside the sources'
folders, and every subscriptions answer lists it, so an agent knows what
it may filter on; a filter naming a field no recent event had is added
with an unseen warning. The note quotes an event's other fields.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFwzbMU5CpudVHy4TZ

* Lookout filters: whole numbers compare exactly past a float; unseen names only fields that keep a filter from matching

Codex review on #532: equal() turned both sides into f64, so integer IDs
past 2^53 compared equal; whole numbers now compare as i64/u64. The unseen
warning named every field a filter mentioned, even under exists:false or
in one $or branch while another could match; pattern::missing now names
only fields that keep the pattern from matching an event with the fields
a source lately had.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFwzbMU5CpudVHy4TZ

---------

Co-authored-by: Claude <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T06:09:12.800823Z a760de7 PR opened
🔒 Security Review ✅ Completed 2026-11-01T06:09:27.011026Z a760de7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a760de7966

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +675 to +678
let example = about["example"].as_str().unwrap_or_default();
(
field.clone(),
json!(format!("{}, as {example}", kinds.join(" or "))),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep live event examples out of unrelated subscription results

When an agent calls subscriptions, subs::change passes every configured source to listed, which returns recent payload examples without checking the caller's subscriptions or filters. Consequently, an agent subscribed only to billing events can receive text and other field values from a rejected search event—or from a source it never subscribed to—through this tool result. These examples also bypass the outside-content warning attached to normal source notes. Return field names and types globally, but omit live payload examples or restrict them to events the caller actually hears.

Useful? React with 👍 / 👎.

Comment on lines +605 to +609
let _ = std::fs::create_dir_all(dir);
// Written whole, then moved in, so a reader never reads half a file.
let partial = self.file.with_extension("json.partial");
if std::fs::write(&partial, format!("{:#}\n", self.to_json())).is_ok() {
let _ = std::fs::rename(&partial, &self.file);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Move shape persistence off the lookout's runtime thread

For a busy source whose fields change, Shape::saw calls flush immediately, bypassing the 60-second interval, and these synchronous filesystem operations run directly inside the source's Tokio task. The lookout uses one current_thread runtime (lookout::main), so slow writes or sustained schema churn block daemon-event consumption, tool handling, and notifications for every subscriber, even when no subscription matches the source's events. Persist shapes through an asynchronous or blocking-worker path and coalesce pending writes so outside event traffic cannot monopolize the shared lookout.

Useful? React with 👍 / 👎.

Comment on lines +211 to +216
("numeric", Value::Array(terms)) => {
let (Some(n), Ok(terms)) = (got.as_f64(), numeric(terms)) else {
return false;
};
terms.iter().all(|(op, bound)| match *op {
"=" => n == *bound,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve integer precision in numeric filters

For event fields containing integers above 2^53, converting both the event value and comparison bounds to f64 silently changes filter results. For example, {"sequence":[{"numeric":[">",9007199254740992]}]} rejects an event with sequence: 9007199254740993, while an equality comparison against the smaller number incorrectly accepts it. This affects large sequence IDs and nanosecond timestamps, which the parser and filter validator accept without restriction. Compare integer operands exactly, as the literal matcher already does, or explicitly reject operands outside the supported precision range instead of silently misrouting events.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant