Repository navigation
feat(observe): import a host's process events as a second sensor - #187
Merged
Merged
Conversation
P1 built and reviewed in two rounds; P2 tests written red first, the implementation they wait for not yet in. Signed-off-by: Konrad Karauda <konrad@karauda.com>
Signed-off-by: Konrad Karauda <konrad@karauda.com>
Signed-off-by: Konrad Karauda <konrad@karauda.com> # Conflicts: # docs/index.md # site/docs/index.html # site/llms.txt # site/sitemap.xml
…WIP) Signed-off-by: Konrad Karauda <konrad@karauda.com>
…put directory (WIP) Signed-off-by: Konrad Karauda <konrad@karauda.com>
…unseen process rows (WIP) Signed-off-by: Konrad Karauda <konrad@karauda.com>
Signed-off-by: Konrad Karauda <konrad@karauda.com> # Conflicts: # CHANGELOG.md # site/docs/changelog.html
Signed-off-by: Konrad Karauda <konrad@karauda.com>
|
Cloudflare builds and deploys previews for this pull request. Learn more about Cloudflare previews.
Updated: |
Signed-off-by: Konrad Karauda <konrad@karauda.com>
Walk the input's path from the root as the gateway's config walk does, refuse a shared directory that is not sticky anywhere on it, take from a sticky shared directory only root's or its owner's entry, refuse a path naming no file, and drop a user or executable that prints blank or holds '='. Signed-off-by: Konrad Karauda <konrad@karauda.com>
In a sticky directory others may write, another account can create a directory first and own what lies under it; judge each directory and link the walk passes there by its owner as the file is, and take this account's entries too, which no other account made. The codec checks a process's user with the importer's account shape, so a line the importer would drop is not taken from the log either. Signed-off-by: Konrad Karauda <konrad@karauda.com>
Signed-off-by: Konrad Karauda <konrad@karauda.com> # Conflicts: # CHANGELOG.md # docs/adr/README.md # docs/index.md # site/docs/changelog.html # site/docs/index.html # site/llms.txt # site/sitemap.xml
…written In a sticky directory others may write, a hard link lets another account put a file it does not own under the input's name: refuse a file with more than one name there. Walk the directory part as written, so .. after a link names what the kernel opens. Test the judge of the directory the file is opened through. Refuse an executable holding a rune other than white space that prints blank anywhere, and name three more blank runes. Signed-off-by: Konrad Karauda <konrad@karauda.com>
…ser shape The trust sections, the record, the changelog and the status page say that every directory on an independent input's path is judged, what a sticky shared directory takes, that a path naming no file is refused, and the shape a process's user and executable keep. Signed-off-by: Konrad Karauda <konrad@karauda.com>
…nter Signed-off-by: Konrad Karauda <konrad@karauda.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed, and why
Backlog B35 asks for a process sensor independent of the agent. ADR-0095 amends ADR-0069’s statement that adding a kind takes only a table row. It adds
host-process-eventsas the third observation kind. A separate sensor writes process starts to a JSON Lines log on the agent’s host. The log must be outside the agent’s control. The descriptor maps time, PID, PPID, executable and user.observe/v1alpha1, outside the v1 promise, addsSUBJECT_KIND_PROCESS = 5, aProcessmessage with PID, PPID and user on the observation, and ahost_process_eventsdescriptor member. Descriptor schema0.3adds the source. Record schema0.4admits a process observation or an import report for this kind.superviserefuses process sources. A refused process line givessuperviseno run to mark as doubtful.internal/ingest/proclogreads only mapped members. It requires one JSON object with unique members, a readable time and a valid executable. The executable must be an absolute, clean path of at most 4,096 bytes. White space is allowed only inside a path element. Other runes that print blank are refused anywhere, and a path element cannot start with a mark. Runes that print blank include white space, Hangul fillers,U+2800,U+303F,U+16FE4,U+1D159, other default-ignorable code points and variation selectors. The importer drops and counts malformed PID, PPID and user values. A user must be copyable text of at most 64 bytes with no=or rune that prints blank, or plain digits with a value at most 4,294,967,295.observe.ValidUserchecks this shape. The observation codec refuses process lines with invalid users on read and write. The importer derives the observation ID by hashing the domainobservation-id:process:1and the process content with SHA-256.coveragemarks aprocesspath observed when a live process source listed for that path saw the executable. Tool observations no longer count toward process coverage. It prints up to 256 rows for undeclared executables, rows for refused lines and an unseen row for each process source that is not live. Any of these conditions makescoverageexit1. The inventory requires absolute, clean process paths and refusesserver_addresson process sources.TRUST_INDEPENDENT,files.ReadUnswappablewalks the input path from/as written, following symbolic links. As in kernel path resolution,..after a link goes to the parent of the link’s target. The walk usesfiles.WalkJudged, moved unchanged from the gateway’s configuration check. The gateway keeps its own judges and behavior. Every directory on the path must be sticky if the group or others can write it. In a sticky shared directory, each directory, link and file the walk encounters must belong to root, the shared directory’s owner or the importing account. The input file in such a directory must have exactly one hard link. The reader refuses paths ending in a separator or in.or..before any open. It judges the last directory again on the handle it uses to open the file. TheLstatresult for the name must match the opened file. The checks use mode bits and owner IDs and exclude access control lists. Owner comparisons apply only in sticky shared directories because the importer cannot identify the agent’s account.Invariant or record
ADR-0095 is new and accepted. ADR-0069 points to it. Under invariant 9, the importer reads only mapped members. The importer drops a command line mapped as the user if it fails
observe.ValidUser. A command line mapped as the executable is copied if it passes the path check. The ADR and reference page assign responsibility for the mapping to the operator.Under invariants 4 and 5, refused lines and process sources that are not live count as unknown and make
coverageexit1. The guarded trees add only three imports,slices,strconvandstrings. The import check reported 0 violations. The wire compatibility check passed. The package is outside the v1 comparison, and the v1 wire schema is unchanged.Version
0.20reads a log containing a0.4record as damaged and a0.3descriptor as an unknown version. Remove the source’s log before rolling back after a process import.How it was tested
coverageemitting no row for a process source that was not live and exiting0. It now emits an unseen row and exits1. Tests also reproduced independent imports accepting an input in a0777directory, an input swapped through a test hook, and an input reached through a symbolic link. Round 3 added regression tests for a command line rejected as a user and for executable path elements that display as empty. Each regression test failed on the round-2 tree before the fix./that was later removed./etc/hostsunder the input name in/tmp. Linux blocks this withfs.protected_hardlinksenabled. Cleaning..after a link before walking the path selected a different file from the one the kernel opens. The second check of the last directory lacked a test. Invisible runes could appear inside executable path elements. Tests for all four findings failed on the earlier tree and passed after the fixes. The fixes killed 13 mutants. On Linux, the importer refused a real second account’s file, directory and link in a root-owned sticky directory and read the importing account’s own entries.filespassed 61 tests with 2 pre-existing skips,observepassed 157,proclog136,egresslog218,ingest65,coverage383,gatewayconfig696 with 1 skip, andcmd/guardana-control886. Thefiles,observeandproclogtests passed in the Linux container. The samecmd/guardana-controlandgatewayconfigtests failed on this branch and on the base commit there. The container lacks the toolchain binary, and itstmpfslacks access control list support.vet. A real concurrent swap betweenLstatand open, macOS hard links to a root-owned file with mode0600, Linux withfs.protected_hardlinks=0, and access control lists remain unverified.Documentation
Added
docs/reference/host-process-events.md, ADR-0095 and its index row, and a pointer in ADR-0069. Updated the observations, channels and versions references, the glossary, where-it-fits and the observations concept page. The trust sections of the host process events and egress access log references, the egress guide, ADR-0095 item 6, the changelog and the status page now describe the path walk and its checks. The coverage reference’s check sentence also describes the rules. The status row and section now sayexperimental. The changelog has entries under Added and Changed.The remaining pages flagged by the documentation impact check cover the CLI, the gateway configuration's path walk, which moved without a change in behaviour, or packages as a whole and need no edits for this change. Backlog row B35 and the roadmap line move at the release.