T03 · Remote Payload Retrieval and Execution
- Location
- references/ksef-troubleshooting.md:448
- Finding
- Unpinned Remote Repository Is Cloned and Executed<![CDATA[ ## Vulnerability Details **File Location**: `references/ksef-troubleshooting.md:448-450` **Vulnerability Type**: Remote payload retrieval and supply-chain execution **Risk Level**: Medium ### Vulnerable Code ```bash git clone https://github.com/CIRFMF/ksef-latarnia cd ksef-latarnia python check_status.py ``` ### Technical Analysis The troubleshooting procedure clones the current, mutable state of an external Git repository and immediately executes `check_status.py`. It does not pin a reviewed commit or signed release, verify a checksum or signature, inspect the retrieved code, or isolate its execution. Consequently, the code that ultimately runs can change after this Skill has been reviewed. The repository is relevant to KSeF status monitoring and is hosted on a recognizable platform, so the instructions do not establish malicious intent. Nevertheless, this is an unsafe remote-code and supply-chain pattern. The Skill itself is instruction-only and does not automatically execute the commands. Exploitation requires a user or integrating agent to follow the documented procedure. ### Attack Path 1. An attacker compromises the upstream repository, a maintainer account, or an upstream dependency used by `check_status.py`. 2. The attacker modifies the repository’s default branch to include malicious Python code. 3. A user follows the troubleshooting instructions and clones the repository without selecting a trusted revision. 4. The user runs `python check_status.py`. 5. The modified script executes with the privileges and environment of that user. 6. If the process has access to KSeF secrets or accounting files, the malicious code may read or transmit them, modify local files, or perform further network activity. ### Impact Assessment Successful exploitation provides arbitrary code execution under the account that runs the command. The attainable scope is limited by that account’s operating-system permissions and execution environment, but may inc ...[truncated 480 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace the mutable default-branch clone with a specific, previously reviewed commit or signed release. 2. Verify the release signature or a publisher-provided cryptographic checksum before execution. 3. Review `check_status.py` and its dependency declarations before running it. 4. Install dependencies from a locked file with hashes rather than accepting mutable dependency versions. 5. Run the utility in a disposable virtual environment or container with: - No KSeF tokens or encryption keys. - A read-only filesystem where practical. - No access to production accounting data. - Restricted outbound network access. - No administrator or root privileges. 6. Prefer an official, documented status endpoint that can be queried directly without executing downloaded code. 7. Clearly warn users that repository content is external code and must not be executed solely because it appears in the Skill documentation. A safer pattern would be: ```bash git clone https://github.com/CIRFMF/ksef-latarnia cd ksef-latarnia git checkout <reviewed-full-commit-hash> git verify-commit <reviewed-full-commit-hash> # Review code and dependencies before execution. python -I check_status.py ``` Commit verification is only effective when the expected signer and commit hash are obtained through a trusted channel. ]]>
