Back to skill

Security audit

KIS Trading (한국투자증권)

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real KIS stock-trading skill, but it can submit live orders and handle brokerage credentials without enough enforced safeguards.

Review this carefully before installing. Use virtual trading first, keep KIS credentials out of logs and transcripts, validate that BASE_URL is one of the official KIS endpoints, and do not allow an agent to run scripts/order.py for live trading unless you have separately confirmed the exact account, side, stock code, quantity, price, and environment.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/kis_common.py:43
Finding

Credentials and Financial Data Can Be Transmitted to an Arbitrary Configured Server

Content
View full analysis
= 10 else '01', 'base_url': section.get('BASE_URL', 'https://openapi.koreainvestment.com:9443'), } ``` ```python url = f"{cfg['base_url']}/oauth2/tokenP" body = { "grant_type": "client_credentials", "appkey": cfg['app_key'], "appsecret": cfg['app_secret'], } headers = {"Content-Type": "application/json"} resp = requests.post(url, json=body, headers=headers, timeout=10) ``` ```python url = f"{cfg['base_url']}{path}" headers = { "Content-Type": "application/json; charset=utf-8", "authorization": f"Bearer {token}", "appkey": cfg['app_key'], "appsecret": cfg['app_secret'], "tr_id": tr_id, "custtype": "P", } resp = requests.get(url, headers=headers, params=params, timeout=10) ``` ```python url = f"{cfg['base_url']}{path}" headers = { "Content-Type": "application/json; charset=utf-8", "authorization": f"Bearer {token}", "appkey": cfg['app_key'], "appsecret": cfg['app_secret'], "tr_id": tr_id, "custtype": "P", } if use_hashkey: try: hk_resp = requests.post( f"{cfg['base_url']}/uapi/hashkey", headers=headers, json=body, timeout=5 ) if hk_resp.status_code == 200: headers['hashkey'] = hk_resp.json().get('HASH', '') except: pass resp = requests.post(url, headers=headers, json=body, timeout=10) ``` ### Technical Analysis The application treats `BASE_URL` from the configuration file as trusted without validating its scheme, hostname, or port. It then sends the KIS application key and secret to that origin during token issuance ...[truncated 2000 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/order.py:83
Finding

Live Stock Orders Are Submitted Without Enforced User Confirmation

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/setup.py:20
Finding

Setup Command Exposes Authentication and Account Material in Output

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/kis_common.py:53
Finding

OAuth Token Cache Is Not Scoped to Its Credential and Endpoint Context

Content
View full analysis
Optional[str]: """토큰 파일 로드 (유효한 경우만)""" try: with open(_TOKEN_FILE) as f: data = json.load(f) if data.get('expired') and datetime.strptime(data['expired'], '%Y-%m-%d %H:%M:%S') > datetime.now(): return data['token'] except: pass return None def get_token(cfg: dict) -> str: """액세스 토큰 발급/캐시""" # 캐시 확인 cached = _load_token() if cached: return cached ``` ### Technical Analysis All configurations share a single token file. The cached record contains only the token and expiration time; it is not bound to the KIS environment, endpoint, application key, or account. A token obtained for one configuration can therefore be returned while another configuration is active. This becomes particularly significant because API request destinations are derived from the current configuration. A valid token cached under an official endpoint may be reused and sent in a subsequent request constructed from a different `BASE_URL`. The file is also opened and written before `chmod(0600)` is called. Its initial permissions are controlled by the process umask, creating a possible exposure window on first creation. The broad exception handling can silently suppress permission or parsing problems. ### Attack Path 1. A legitimate command ...[truncated 1120 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Rogue AgentSelf-Modification, Session Persistence
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (22)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
96% confidence
Finding

The skill invokes Python scripts that can access the filesystem, execute shell commands, and make network requests to a live brokerage API, but it does not declare any explicit tool scope such as permissions or allowed-tools. In a trading skill, this omission is especially risky because the capability set includes live order placement and access to sensitive credentials/configuration, so an agent runtime may grant broader powers than users expect.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This reference explicitly documents live buy, sell, and cancel endpoints for a production trading API but provides no safety guidance about irreversible financial actions, testing in mock mode first, or guarding against unintended execution. In a trading skill context, that omission increases the chance that downstream agents or users will invoke real-money operations without adequate confirmation or environment separation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The guide includes sensitive authentication material such as bearer tokens and app secrets in the common header example without any warning about secure storage, redaction, or avoiding logs. In a skill that handles brokerage access, exposed credentials could enable unauthorized account access, data retrieval, or order placement if copied into prompts, logs, or shared transcripts.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring and CLI description are written only in Korean, which imposes a specific language on users without opt-in or explanation. Under the language/locale policy, this is a natural-language constraint that should either be optional or clearly justified.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/kis_common.py (reported line 23)May include surrounding context.

python
if not os.path.exists(config_path):
        print(f"❌ 설정 파일을 찾을 수 없습니다: {config_path}")
        print(f"📝 설정 파일을 생성하세요:")
        print(f"   mkdir -p ~/.kis-trading")
        print(f"   cp config.ini.example ~/.kis-trading/config.ini")
        sys.exit(1)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This function sends the configured app key and app secret to a remote API endpoint to obtain an access token, but the only description is a brief internal docstring and there is no user-facing warning, confirmation, or disclosure about transmitting credentials over the network. Under the code-file criteria, access to sensitive credentials and network transmission should be flagged when no visible warning is present and the action is not explicitly disclosed to the user.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · scripts/kis_common.py (reported line 94)May include surrounding context.

python
}
    headers = {"Content-Type": "application/json"}

    resp = requests.post(url, json=body, headers=headers, timeout=10)
    if resp.status_code != 200:
        print(f"❌ 토큰 발급 실패: {resp.status_code} {resp.text}")
        sys.exit(1)

Tainted flow: 'headers' from requests.post (line 152, network input) → requests.post (network output)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · scripts/kis_common.py (reported line 94)May include surrounding context.

python
}
    headers = {"Content-Type": "application/json"}

    resp = requests.post(url, json=body, headers=headers, timeout=10)
    if resp.status_code != 200:
        print(f"❌ 토큰 발급 실패: {resp.status_code} {resp.text}")
        sys.exit(1)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The GET helper includes the bearer token, app key, and app secret in outbound request headers, and sends request parameters to the remote API, but the code provides no visible warning beyond an internal technical docstring. This matches the missing-warning category for code files because it performs network transmission of sensitive authentication material without user disclosure in code comments, prints, or referenced documentation.

Content

No source excerpt is available for this finding.

Tainted flow: 'headers' from requests.post (line 152, network input) → requests.get (network output)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · scripts/kis_common.py (reported line 129)May include surrounding context.

python
"tr_id": tr_id,
        "custtype": "P",
    }
    resp = requests.get(url, headers=headers, params=params, timeout=10)
    if resp.status_code != 200:
        print(f"❌ API 오류: {resp.status_code} {resp.text[:200]}")
        return None

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

This function sends bearer tokens, app credentials, and arbitrary POST bodies to external API endpoints, including an additional hashkey request, yet there is no user-facing warning, confirmation, or explanatory comment describing that sensitive data may be transmitted. For code files, outbound network calls involving credentials or user/system data should be disclosed unless clearly covered elsewhere, which is not visible in this file.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · scripts/kis_common.py (reported line 164)May include surrounding context.

python
# 해시키 설정
    if use_hashkey:
        try:
            hk_resp = requests.post(
                f"{cfg['base_url']}/uapi/hashkey",
                headers=headers, json=body, timeout=5
            )

Tainted flow: 'headers' from requests.post (line 152, network input) → requests.post (network output)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · scripts/kis_common.py (reported line 164)May include surrounding context.

python
# 해시키 설정
    if use_hashkey:
        try:
            hk_resp = requests.post(
                f"{cfg['base_url']}/uapi/hashkey",
                headers=headers, json=body, timeout=5
            )

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · scripts/kis_common.py (reported line 173)May include surrounding context.

python
except:
            pass

    resp = requests.post(url, headers=headers, json=body, timeout=10)
    if resp.status_code != 200:
        print(f"❌ API 오류: {resp.status_code} {resp.text[:200]}")
        return None

Tainted flow: 'headers' from requests.post (line 152, network input) → requests.post (network output)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · scripts/kis_common.py (reported line 173)May include surrounding context.

python
except:
            pass

    resp = requests.post(url, headers=headers, json=body, timeout=10)
    if resp.status_code != 200:
        print(f"❌ API 오류: {resp.status_code} {resp.text[:200]}")
        return None

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This code file contains natural-language strings such as the module docstring, argparse description/help text, and printed output entirely in Korean. Under the stated policy, forcing a specific language without offering user choice or documenting a justified locale constraint is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This script performs a real buy/sell order immediately after printing a warning, but it does not require an explicit interactive confirmation or equivalent acknowledgement before calling the trading API. In a stock-trading skill, that creates a meaningful risk of accidental unauthorized or unintended trades from mistyped parameters, automation mistakes, or prompt/agent misuse, leading directly to financial loss.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code includes the module description, argument help text, error messages, and output labels entirely in Korean. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly documented and justified, which is not present here.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script prints the first part of the access token to stdout, which exposes sensitive credential material to terminals, shell history captures, CI logs, remote session transcripts, or centralized log collectors. Even partial token disclosure is unnecessary and increases the risk of credential leakage, especially in a trading skill where the token authorizes access to brokerage APIs.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

This script performs a network request to retrieve sensitive financial account information, using account identifiers from configuration and an authentication token. Although the script prints the resulting balance, there is no confirmation prompt, warning, or explanatory comment/docstring disclosing the external API access to sensitive financial data.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

This Python file makes an HTTP/API request to a brokerage endpoint that transmits account identifiers and retrieves sensitive portfolio data. Within this file, there is no confirmation prompt, visible notice, or explanatory comment/docstring warning the user that financial account data will be sent to and fetched from a remote service.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

All natural-language strings in the script, including description, warnings, and operational output, are presented only in Korean. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly justified.

Content

No source excerpt is available for this finding.