The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: keep forged local profiles out of messaging authorization fallback
Tekniumd379d6cc1d08
diff --git a/gateway/session_local.py b/gateway/session_local.pyindex 112f6416a2c..aacf65bd3d6 100644--- a/gateway/session_local.py+++ b/gateway/session_local.py@@ -65,7 +65,11 @@ class LocalSessionAdapter(BasePlatformAdapter):def authorize_local_source(runner, source):"""None for legacy/nonlocal routes; registered local adapters fail closed."""- adapter = runner._adapter_for_source(source)+ if source.platform != Platform.LOCAL:+ return None+ # A forged profile must not miss this adapter and fall into a messaging+ # allow-all policy. Local source identity is owned by this authority alone.+ adapter = runner._primary_adapters().get(Platform.LOCAL)if not isinstance(adapter, LocalSessionAdapter):return Noneif adapter.authority is not getattr(runner, 'session_authority', None):diff --git a/tests/gateway/fixtures/local_session_peer.py b/tests/gateway/fixtures/local_session_peer.pyindex a671297d7e6..e6f675012a2 100644--- a/tests/gateway/fixtures/local_session_peer.py+++ b/tests/gateway/fixtures/local_session_peer.py@@ -60,6 +60,30 @@ async def probe(peer, target):assert info['result']['source'] == 'cli', infoassert info['result']['lazy'] is True, infoassert authority.db.get_session(sid) is not None+ # Private route identity cannot be reconstructed from its serialized source,+ # even under an unrelated messaging allow-all policy.+ from dataclasses import replace+ source = authority.sessions[sid].source+ assert runner._is_user_authorized_for_source(source)+ os.environ['GATEWAY_ALLOW_ALL_USERS'] = 'true'+ try:+ assert not runner._is_user_authorized_for_source(replace(source, role_authorized=True))+ assert not runner._is_user_authorized_for_source(replace(source, profile='foreign'))+ finally:+ os.environ.pop('GATEWAY_ALLOW_ALL_USERS')+ from gateway.session_local import create_local_session+ from gateway.session_contract import Principal+ from hermes_state_runtime import RuntimeStoreError+ for actor, reason in ((Principal('read-only', 'fixture', frozenset({'session:read'}), 'readonly'),+ 'permission_denied'),+ (Principal('creator', 'foreign', frozenset({'session:create'}), 'foreign'),+ 'profile_mismatch')):+ try:+ create_local_session(authority, actor, {})+ except RuntimeStoreError as exc:+ assert exc.reason == reason+ else:+ raise AssertionError('restricted principal created a local route')repeated = await rpc(a, 'session.create', request_id='fresh', source='cli')assert repeated['result']['session_id'] == sid, repeatedb = await connect()