Back to skill

Security audit

byteplan-api

Security checks for vulnerabilities and agentic risk

Overview

This BytePlan API skill appears purpose-aligned, but it automatically stores account passwords and reusable tokens in plaintext and may write them to an unexpected project .env file.

Review before installing. Use only with a BytePlan account you are comfortable authenticating through this skill, prefer the UAT environment, and assume your password plus access and refresh tokens may be written to a local .env file. Check both your project .env and skill-related directories after use, keep those files out of source control and backups, and rotate/revoke credentials if they were exposed.

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 (1)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/api.js:18
Finding

Plaintext credentials and reusable tokens are persisted to an unsafe, undocumented location

Content
View full analysis
{ const trimmed = line.trim(); if (!trimmed || trimmed.startsWith('#')) return true; const key = trimmed.split('=')[0]?.trim(); return !keysToUpdate.includes(key); }); const configLines = []; configLines.push(`BP_ENV=${currentEnv}`); configLines.push(`BP_USER=${username}`); configLines.push(`BP_PASSWORD="${password}"`); configLines.push(`ACCESS_TOKEN=${access_token}`); if (refresh_token) { configLines.push(`REFRESH_TOKEN=${refresh_token}`); } if (expires_in) { configLines.push(`TOKEN_EXPIRES_IN=${Date.now() + expires_in * 1000}`); } const finalLines = [...preservedLines, ...configLines]; const finalContent = finalLines.join('\n'); ...[truncated 4541 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (36)

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The skill explicitly states that the dev environment transmits passwords in plaintext, yet it presents that option as a normal selectable environment without a strong warning or forced confirmation. Plaintext password transmission can expose account credentials to interception by anyone able to observe the network path, making compromise immediate and severe.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

The documented directory structure identifies ~/.byteplan/.env as a global shared location for credentials and tokens. In the context of a reusable API skill depended on by other skills, centralizing secrets in a predictable plaintext path increases exposure and makes credential harvesting by any local code with file access more practical.

Content

Scanner excerpt · SKILL.md (reported line 70)May include surrounding context.

目录结构:

text
~/.byteplan/
├── .env              # 凭证和 token(全局共享)
└── workspaces/       # 各分析主题的工作目录(可选)
    ├── 计算机资产折旧_20260331_224600/
    │   ├── analysisPlan.json

Credential Access

High
Category
Privilege Escalation
Confidence
94% confidence
Finding

The persistence flow explicitly describes automatic saving of authentication tokens to ~/.byteplan/.env after login. Automatic credential/token persistence without strong isolation or consent increases the blast radius of any local compromise and can enable silent reuse of stolen sessions.

Content

Scanner excerpt · SKILL.md (reported line 167)May include surrounding context.

text
1. 用户输入账号密码 → login()
2. 登录成功 → 自动创建 ~/.byteplan/ 目录
3. 自动保存 ACCESS_TOKEN, REFRESH_TOKEN, TOKEN_EXPIRES_IN 到 ~/.byteplan/.env
4. 后续调用 → loginWithEnv() 自动使用缓存 token
5. token 过期 → 自动重新登录并更新 ~/.byteplan/.env

Credential Access

High
Category
Privilege Escalation
Confidence
94% confidence
Finding

This section reiterates updating cached tokens in a shared ~/.byteplan/.env file as part of the automatic refresh flow. Continuously refreshing and rewriting secrets in a common plaintext file creates a durable target for theft and can keep compromised access alive longer than necessary.

Content

Scanner excerpt · SKILL.md (reported line 169)May include surrounding context.

  1. 登录成功 → 自动创建 ~/.byteplan/ 目录
  2. 自动保存 ACCESS_TOKEN, REFRESH_TOKEN, TOKEN_EXPIRES_IN 到 ~/.byteplan/.env
  3. 后续调用 → loginWithEnv() 自动使用缓存 token
  4. token 过期 → 自动重新登录并更新 ~/.byteplan/.env
text

### 用户与租户

Credential Access

High
Category
Privilege Escalation
Confidence
93% confidence
Finding

The example code shows a fixed credential file path under the user's home directory, making secret location predictable and easy for other local tools or skills to probe. Predictable storage is especially risky here because the skill is intended as a shared dependency for multiple other skills.

Content

Scanner excerpt · SKILL.md (reported line 325)May include surrounding context.

md
// 凭证文件路径
const BYTEPLAN_DIR = path.join(homedir(), '.byteplan');
const ENV_FILE = path.join(BYTEPLAN_DIR, '.env');

// 用户选择的环境
let selectedEnv = 'dev';

Credential Access

High
Category
Privilege Escalation
Confidence
93% confidence
Finding

The code path attempts automatic login from ~/.byteplan/.env, meaning any actor that can populate or read that file may influence or hijack authentication state. In a shared-skill ecosystem, automatic trust of locally stored credentials makes credential misuse and session confusion more likely.

Content

Scanner excerpt · SKILL.md (reported line 330)May include surrounding context.

md
// 用户选择的环境
let selectedEnv = 'dev';

// 尝试使用 ~/.byteplan/.env 凭证登录
let token;
if (existsSync(ENV_FILE)) {
  try {

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/api.js (reported line 19)May include surrounding context.

js
let currentEnv = process.env.BP_ENV || 'dev';

/**
 * 获取 .env 文件路径
 * @returns {string}
 */
function getEnvPath() {

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/api.js (reported line 34)May include surrounding context.

js
let currentEnv = process.env.BP_ENV || 'dev';

/**
 * 获取 .env 文件路径
 * @returns {string}
 */
function getEnvPath() {

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/api.js (reported line 57)May include surrounding context.

js
let currentEnv = process.env.BP_ENV || 'dev';

/**
 * 获取 .env 文件路径
 * @returns {string}
 */
function getEnvPath() {

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/api.js (reported line 298)May include surrounding context.

js
let currentEnv = process.env.BP_ENV || 'dev';

/**
 * 获取 .env 文件路径
 * @returns {string}
 */
function getEnvPath() {

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/api.js (reported line 311)May include surrounding context.

js
let currentEnv = process.env.BP_ENV || 'dev';

/**
 * 获取 .env 文件路径
 * @returns {string}
 */
function getEnvPath() {

Credential Access

High
Category
Privilege Escalation
Confidence
96% confidence
Finding

By targeting process.cwd()/.env, the skill is designed to read secrets from the caller project's environment file rather than a dedicated isolated store. In a shared API dependency, this broad credential access scope is risky because it can ingest unrelated secrets from whichever project invokes it.

Content

Scanner excerpt · scripts/api.js (reported line 25)May include surrounding context.

js
function getEnvPath() {
  // 优先使用调用方的 .env(当前工作目录),其次使用项目根目录
  const cwd = process.cwd();
  const projectEnvPath = path.join(cwd, '.env');
  if (fs.existsSync(projectEnvPath)) {
    return projectEnvPath;
  }

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

The fallback to another .env path under the skill tree shows the code is built to harvest credentials from local environment files. While not exfiltrating them directly, this expands the locations from which the skill can access secrets and normalizes plaintext secret handling.

Content

Scanner excerpt · scripts/api.js (reported line 29)May include surrounding context.

js
if (fs.existsSync(projectEnvPath)) {
    return projectEnvPath;
  }
  // 回退到 skill 目录的 .env
  return path.join(getDirname(), '..', '..', '.env');
}

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

Returning a fallback .env path contributes to the skill's ability to access secrets from local files outside explicit runtime parameters. In the context of a reusable dependency, this broad secret discovery behavior is more dangerous because consuming skills may unknowingly grant it access to stored credentials.

Content

Scanner excerpt · scripts/api.js (reported line 30)May include surrounding context.

js
return projectEnvPath;
  }
  // 回退到 skill 目录的 .env
  return path.join(getDirname(), '..', '..', '.env');
}

/**

Credential Access

High
Category
Privilege Escalation
Confidence
99% confidence
Finding

This function explicitly saves credentials to a .env file, including plaintext password and tokens. That is direct credential handling on local storage and materially raises the likelihood of credential compromise through filesystem exposure, logs, backups, or source-control mistakes.

Content

Scanner excerpt · scripts/api.js (reported line 46)May include surrounding context.

js
}

/**
 * 保存凭证到 .env 文件
 * @param {Object} credentials - 凭证对象
 * @param {string} credentials.username - 用户名
 * @param {string} credentials.password - 密码

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

Credentials and tokens are written to disk without any user-facing warning, consent, or disclosure. Silent persistence of secrets is dangerous because users may assume login is ephemeral, while the skill leaves recoverable plaintext secrets that can be read by other local processes, backup systems, or accidentally committed to source control.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
99% confidence
Finding

At this point in the login flow, the code persists newly obtained secrets to .env after authenticating. This turns transient authentication data into local plaintext stored secrets, increasing exposure well beyond the active session.

Content

Scanner excerpt · scripts/api.js (reported line 281)May include surrounding context.

js
throw new Error(`登录失败: ${data.message || data.error_description || JSON.stringify(data)}`);
  }

  // 保存凭证到 .env
  try {
    saveCredentials({
      username,

Credential Access

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

The function reads username and password from process environment variables, enabling the skill to consume stored credentials automatically. This is common in tooling, but in this context it becomes risky because the same module also discovers and rewrites shared .env files, compounding secret exposure.

Content

Scanner excerpt · scripts/api.js (reported line 308)May include surrounding context.

js
const password = process.env.BP_PASSWORD || process.env.PASSWORD;

  if (!username || !password) {
    throw new Error('请在 .env 中配置 BP_USER 和 BP_PASSWORD(或 USER_NAME 和 PASSWORD)');
  }

  // 如果指定了环境,使用指定环境;否则从 .env 读取

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/api.js (reported line 345)May include surrounding context.

js
/**
 * 获取用户信息
 * @param {string} token - access token
 * @returns {Promise<{user: object, tenantList: array}>}
 */
export async function getUserInfo(token) {

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/api.js (reported line 364)May include surrounding context.

js
/**
 * 获取用户信息
 * @param {string} token - access token
 * @returns {Promise<{user: object, tenantList: array}>}
 */
export async function getUserInfo(token) {

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/api.js (reported line 394)May include surrounding context.

js
/**
 * 获取用户信息
 * @param {string} token - access token
 * @returns {Promise<{user: object, tenantList: array}>}
 */
export async function getUserInfo(token) {

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/api.js (reported line 422)May include surrounding context.

js
/**
 * 获取用户信息
 * @param {string} token - access token
 * @returns {Promise<{user: object, tenantList: array}>}
 */
export async function getUserInfo(token) {

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/api.js (reported line 473)May include surrounding context.

js
/**
 * 获取用户信息
 * @param {string} token - access token
 * @returns {Promise<{user: object, tenantList: array}>}
 */
export async function getUserInfo(token) {

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/api.js (reported line 495)May include surrounding context.

js
/**
 * 获取用户信息
 * @param {string} token - access token
 * @returns {Promise<{user: object, tenantList: array}>}
 */
export async function getUserInfo(token) {

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/api.js (reported line 528)May include surrounding context.

js
/**
 * 获取用户信息
 * @param {string} token - access token
 * @returns {Promise<{user: object, tenantList: array}>}
 */
export async function getUserInfo(token) {