Skip to content

The agent that grows with you

fix: refuse unrouted profile claims in native callback snapshots

Teknium99c923bc8b6b
diff --git a/gateway/session_ingress_context.py b/gateway/session_ingress_context.py
index 9513d008502..bf847efdab2 100644
--- a/gateway/session_ingress_context.py
+++ b/gateway/session_ingress_context.py
@@ -42,6 +42,8 @@ def _binding(runner, source, profile):
raise RuntimeStoreError('profile_mismatch')
runtime_home = home
multiplex = getattr(runner.config, 'multiplex_profiles', False)
+ if not multiplex and source.profile:
+ raise RuntimeStoreError('profile_mismatch')
if multiplex:
# Only the reservation-backed server registry proves a served home. Directory
# discovery and _resolve_profile_home_for_source's primary fallback do not.
diff --git a/tests/gateway/fixtures/native_ingress_trust_peer.py b/tests/gateway/fixtures/native_ingress_trust_peer.py
index c16d7d0db4b..04d5246d483 100644
--- a/tests/gateway/fixtures/native_ingress_trust_peer.py
+++ b/tests/gateway/fixtures/native_ingress_trust_peer.py
@@ -72,6 +72,16 @@ async def probe(mode, peer):
else:
raise AssertionError('event trust was accepted: ' + field)
assert not authority.sessions
+ foreign = state / 'profiles' / 'foreign'
+ foreign.mkdir(parents=True)
+ (foreign / 'config.yaml').write_text((state / 'config.yaml').read_text())
+ hostile = adapter.build_source(chat_id='forged-profile', chat_type='dm', user_id='fixture-user')
+ hostile.profile = 'foreign'
+ await adapter.handle_message(MessageEvent(text='FORGED_PROFILE', source=hostile, message_id='foreign-profile'))
+ async with asyncio.timeout(10):
+ while adapter._active_sessions:
+ await asyncio.sleep(0.01)
+ assert not authority.sessions, 'unrouted profile field became durable authority'
print(json.dumps({'rejected': rejected}))
return
event = MessageEvent(text='TRUST_CALLBACK_INPUT', source=source, message_id='trust-1')