Garry's Opinionated OpenClaw/Hermes Agent Brain
Key files: Security (continued)
Subsystem index · Previous entries. Read only the entries relevant to your change.
src/core/git-env.ts+src/core/hardened-git.ts— #7584, the operator'ssafe.directoryin scrubbed Git environments:hardenedGitEnvironmentstill drops system and global config and everyGIT_*variable, but carries the operator'ssafe.directoryentries (system and global, read from/withgit config --includes --show-scopeand cached for 30 s, thenGIT_CONFIG_*) as environment config, so a source repository owned by another user reads once the operator allows it.gitChildEnvcarries the environment entries the same way (envSafeDirectories,safeDirectoryEnv). Every other key in those places stays out.gitChildEnvalso drops Git's global pathspec switches (GIT_PATHSPEC_ENV_VARS:GIT_LITERAL_PATHSPECS,GIT_GLOB_PATHSPECS,GIT_NOGLOB_PATHSPECS,GIT_ICASE_PATHSPECS;extracan still set one). gbrain's writers and readers mark each path literal withliteralPathspecs(:(literal)<path>; an empty path throws, since:(literal)alone matches the whole tree, #7793), nevergit --literal-pathspecs, which Git exports to every hook, textconv and filter helper asGIT_LITERAL_PATHSPECS=1, where a hook's glob pathspec then matches nothing;test/git-env-guard.test.tsrejects a global pathspec switch (flag or env) anywhere insrc. GST-2331:NO_LAZY_FETCH_ENV(GIT_NO_LAZY_FETCH=1and an emptyGIT_ALLOW_PROTOCOL) is what a managed-sync read that runs undergitChildEnvadds besideHARDENED_GIT_ARGS, so a partial clone fetches nothing (Git before 2.45 ignores the first; the empty allowlist allows no transport on any Git):syncGit/syncGitAsync, every read insync-blobs.ts,sync-delta.ts's text runner (a rename whose old blob the clone lacks fails the diff,diff_failed, and discovery walks the whole tree),sync-rename-identity.ts,sync-metafile-pages.ts,sync-origin-evidence.ts,sync-held-deletions.ts,unindexed-files.tsandpending-import.ts. Tests:test/hardened-git-safe-directory-7584.test.ts(ownership f... (line truncated to 2000 chars)src/core/outside-content.ts— GBRA-221:neutralizeOutsideText(text), the one neutralizer for text a third party wrote before it lands in a page body (Gmail/Calendar/Contacts renders ingoogle-render.ts, GitHubrenderItemPage/renderRepoCard, chat transcripts intranscripts/render.ts,book-mirrorchapter output). It escapes everygbrain<ws>:<ws><name>marker token togbrain\:<name>(case-insensitive),[Source:to[Source\:, and backslash-prefixes each timeline sentinel, bare## Timeline/## Historyheading, dated timeline row or heading, transcript message anchor and date heading, using the parsers' own predicates. Idempotent and readable; apply it per outside field (or a composed line holding one), never to a whole page that may hold gbrain's own fences or citations. Also ownsescapeAnchorLinesandMESSAGE_ANCHOR_RE(re-exported bytranscripts/render.ts). New connectors use it.src/core/function-search-path.ts— #7632 search_path hardening (#7688, #7785):PINNED_FUNCTION_NAMES(every gbrain function with a pinned search_path;scripts/check-search-path.shfails one missing from it or a pinned path not ending inpg_temp),FUNCTION_SEARCH_PATH_HARDENING_SQL(the schema blob's last statement), andhardenFunctionSearchPaths(v277 and the end of every migration run: one transaction under the migration timeouts, a pg_proc row lock it cannot take becomesschema_lock_blocked, a concurrent pg_proc update is retried, returns the functions left or null when listing them failed; it first re-creates the purge and withdrawal guards its role owns, retrying a concurrent update, and a re-create failure other than SQLSTATE 42501 is thrown asLedgerGuardRecreateErrorafter the hardening runs, whichhardenFailureLineprints as aguards:line). Doctor checks:src/commands/doctor/checks/guard-ledger-checks.ts(guard_ledger_checks, Postgres only: names each guard missing its ledger check, fromledgerGuardsWithoutCheckinsrc/core/guard-ledger-checks.ts, with its owner) andsrc/commands/doctor/checks/function-search-path.ts(function_search_path: names any pinned function whose path does not end inpg_temp; the fix isgbrain apply-migrations --yesbelow v277, else the schema-qualifiedALTER FUNCTIONSQL (argument types only) indetails.sqlto run as the owner, with no runnable fix).src/core/facts/private-fact-pages.ts+src/commands/auth-private-facts.ts+src/commands/auth-client-rows.ts— the per-credential private-facts axis (PrivateFactsGrantnone|granted_sourcesinaccess_tokens.private_factsandoauth_clients.private_facts, migration v319principal_private_facts, defaultnone, never in the legacy permissions mirror; set only by the localgbrain auth rescope --token|--client --private-facts, refused for a credential with scope sources insrc/core/access/attest-sources.ts). MCP dispatch puts the explicitly named sources (as for private pages, never thedefaultfloor) inprivateFactSources()(src/core/search/private-visibility.ts) for remote reads only, never for mutating ops,context_packordelta, an asserted audience, an attested actor, a scope read or an enforced member read;grantedPrivateFactSql(src/core/access/member-facts.ts) admits a private fact only in those sources and only whilefactPagesOpenSqlholds: its holding, provenance (factProvenanceSlugSql) and entity pages are all open (not private,readable_by, folder-ruled, quarantined or a member page,factPageReasons), and it is not unpaged or in a transcript lane (unpagedFactSql).gbrain repair open-factsshares the same page predicate. The hot-memory cache (src/core/facts/meta-hook.ts) keys a granted read as<tier>+xpf=<sorted sources>and the query cache addsxpf=to its knobs hash, so a payload read under the grant never serves a credential without it.auth-private-facts.tsrenders the setting, the rescope before/after lines and the warning;auth-client-rows.tsisgbrain auth clients' listing with a degrade ladder that dropsprivate_facts, thenprivate_pages, on older brains. Tests:test/private-facts-grant-8194.test.ts,test/e2e/private-facts-grant-postgres.test.ts,test/qm-scope-writes.test.ts,test/auth-private-pages-output.test.ts.src/core/access/owner-only.ts— owner-only sources: a source of a kind inOWNER_ONLY_KINDS(imessage) or withowner_only: trueinsources.configis read only by the local CLI and by a credential bound to the brain owner speaking for itself (CallerAccess.owner). Decided at read time fromsources, so nothing is stored per page and no migration runs.ownerOnlyPageSqlandownerOnlyFactSqlmatch a row in an owner-only source, a synthesized concept with aconcept-provenanceinput there, or a row whosederivation_inputs(followed up toOWNER_ONLY_LINEAGE_DEPTHhops) reach a page, fact, take or timeline row there; each leads with one uncorrelatedEXISTSoversources, so a brain with no owner-only source pays one InitPlan.src/core/search/private-visibility.tsappends them to the mandatory member-access part of the page and fact policies (no grant, hatch or lineage switch relaxes them), andsrc/core/persistence/page-visibility.tsrefuses a remote write into an owner-only source from any credential but the owner's (page_not_found).ownerOnlySourcesPresentandsourceIsOwnerOnlyfail closed. Tests:test/imessage-owner-only.test.ts(every caller class under each relaxation),test/e2e/imessage-source-postgres.test.ts.src/core/imessage/+src/core/apple/helper-client.ts— theimessageconnector kind.helper-client.tsreads the GBrain Helper's/v1/imessage/threadsand/v1/imessage/threadover 127.0.0.1 with a bearer token (configapple.helper.port; token fromi_token_env,GBRAIN_CONNECTOR_IMESSAGE_TOKENor~/.gbrain/connectors/imessage.json) and maps the helper's problem codes toapple_helper_not_running,apple_helper_unauthorized,apple_full_disk_access_pendingandapple_schema_mismatch, each of which stops the run.imessage-source.tskeeps a per-chat coverage window (connectors/api-source.ts) with a lookback that re-renders recent days, writes onetype: imessage,visibility: privatepage per chat per day in the source's time zone (render.ts; the chat key is a hash, so no handle reaches a slug, the cursor or a log), always database-recorded and gated at the external-untrusted tier, and deletes a day whose messages were all unsent.source-add.tsissources add --kind imessage(no--diror--record). Tests:test/imessage-source.test.ts,test/helpers/imessage-helper-fixture.ts.