fix(server): refuse an MCP token equal to a sync token

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-26 16:22:14 +01:00
1 parent 4195374c23
commit 053d1f9d90
2 files changed
+23

No files matched your search

+5
View File
@@ -93,6 +93,11 @@ impl Config {
{
return Err("SYNAPSE_MCP_TOKEN has no token".into());
}
if let Some(m) = &self.mcp
&& m.tokens.iter().any(|t| self.auth_tokens.contains(t))
{
return Err("SYNAPSE_MCP_TOKEN must differ from the sync tokens".into());
}
let mcp_tokens = self.mcp.iter().flat_map(|m| m.tokens.iter());
for t in self
.auth_tokens
+18
View File
@@ -185,3 +185,21 @@ async fn writes_go_through_the_op_log() {
assert!(ops.to_string().contains("rejects aliasing"), "{ops}");
srv.shutdown();
}
#[test]
fn mcp_token_must_differ_from_sync_tokens() {
let cfg = Config {
bind: "127.0.0.1:0".parse().unwrap(),
data_dir: "/tmp/unused".into(),
auth_tokens: vec![SYNC_TOKEN.into()],
update_token: None,
update_script: "/nonexistent".into(),
max_clock_skew: Duration::from_secs(600),
mcp: Some(McpConfig {
tokens: vec![SYNC_TOKEN.into()],
allow_write: false,
allowed_hosts: Vec::new(),
}),
};
assert!(cfg.validate().is_err());
}