mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-24 16:54:43 +00:00
fix(slack): warn when slack_tokens.json is group/world-readable
The OAuth multi-workspace token file contains plaintext bot tokens for all saved Slack workspaces. Unlike the Google Chat adapter which sets 0o600 when writing credentials, the Slack token file has no permission enforcement — a default umask 022 makes it world-readable. Fix: check file permissions on read and emit a warning log with remediation instructions if the file is group- or world-readable.
This commit is contained in:
parent
1d7db1ba17
commit
fccc222bd7
1 changed files with 13 additions and 0 deletions
|
|
@ -1623,6 +1623,19 @@ class SlackAdapter(BasePlatformAdapter):
|
|||
tokens_file = get_hermes_home() / "slack_tokens.json"
|
||||
if tokens_file.exists():
|
||||
try:
|
||||
# Warn if the token file is world- or group-readable — it
|
||||
# contains plaintext bot tokens for all saved workspaces.
|
||||
import stat as _stat
|
||||
|
||||
mode = tokens_file.stat().st_mode
|
||||
if mode & (_stat.S_IRGRP | _stat.S_IROTH):
|
||||
logger.warning(
|
||||
"[Slack] %s is group/world-readable (mode 0%o). "
|
||||
"Run: chmod 600 %s",
|
||||
tokens_file.name,
|
||||
_stat.S_IMODE(mode),
|
||||
tokens_file,
|
||||
)
|
||||
saved = json.loads(tokens_file.read_text(encoding="utf-8"))
|
||||
for team_id, entry in saved.items():
|
||||
tok = entry.get("token", "") if isinstance(entry, dict) else ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue