T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/morning_briefing.sh:11
- Finding
- Hard-Coded Cross-User Credential File Access<![CDATA[ ## Vulnerability Details **File Location**: `scripts/morning_briefing.sh:11` **Vulnerability Type**: Cross-user credential access that violates least privilege **Risk Level**: High ### Vulnerable Code ```python API_KEY = open("/home/scott/.config/data-go-kr/api_key").read().strip() ``` ### Technical Analysis The morning briefing script reads an API key from an absolute path belonging to the fixed user `scott`. This conflicts with the documented configuration path, `~/.config/data-go-kr/api_key`, which should resolve to the account invoking the Skill. The weather functionality only requires access to the invoking user's configured API credential. Accessing a different user's home directory is not necessary. If the script is executed by a privileged service, shared automation account, or agent with broad filesystem permissions, it can read and use another user's credential without that user's authorization. Although the key is subsequently transmitted only to the documented HTTPS API host, the initial cross-user credential access violates the principle of least privilege. ### Attack Path 1. A privileged agent, service, or shared automation account invokes `morning_briefing.sh`. 2. The process has permission to read `/home/scott/.config/data-go-kr/api_key`. 3. The script reads Scott's API key regardless of which user initiated the request. 4. The script uses that credential to authenticate requests to KMA and AirKorea. 5. An operator controlling the execution environment can modify the script, trace the process, or intercept diagnostic data to recover or misuse the credential. ### Impact Assessment Successful exploitation permits unauthorized use or disclosure of another local user's data.go.kr API credential. The direct scope is limited to the services and quotas authorized by that key, but abuse may consume quotas, cause service disruption, expose associated usage records, or result in actions being attributed to the credential owner. The iss ...[truncated 317 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Resolve the credential relative to the invoking user's home directory instead of using `/home/scott`: ```python from pathlib import Path key_path = Path.home() / ".config" / "data-go-kr" / "api_key" API_KEY = key_path.read_text(encoding="utf-8").strip() ``` - Alternatively, accept an explicit configuration path through a narrowly scoped environment variable, while rejecting unexpected or untrusted paths. - Verify that the credential file is a regular file, is owned by the invoking user, and is not group- or world-readable. - Refuse to run with an effective user different from the intended account unless privileged execution is explicitly required. - Return a controlled error when the file is absent or inaccessible rather than probing another user's home directory. - Rotate the affected API key if this script has run under accounts capable of reading the hard-coded path. ]]>
