- Location
- scripts/yotta_publish_guard.py:710
- Finding
- Publish workflow can commit and publicly upload unintended sensitive files## Vulnerability Details
**File Location**: `scripts/yotta_publish_guard.py:710-731`
**Vulnerability Type**: Overbroad file staging and publication without secret or package-content enforcement
**Risk Level**: High
### Vulnerable Code
```python
if "github" in channels:
plan.append(("git init", ["git", "init"]))
plan.append(("git add .", ["git", "add", "."]))
plan.append(("git commit", ["git", "commit", "-m",
"feat: initial release v%s" % pkg_v]))
plan.append(("gh repo create",
["gh", "repo", "create", cfg.github_org + "/" + slug, "--public",
"--source=.", "--push", "--description", desc]))
if "npm" in channels:
npm_cmd = ["npm", "publish", "--registry=https://registry.npmjs.org/"]
plan.append(("npm publish", npm_cmd))
if "clawhub" in channels:
plan.append(("clawhub publish",
["clawhub", "publish", str(d),
"--name", "%s %s" % (zh, slug),
"--owner", owner,
"--version", pkg_v,
"--categories", cats,
"--topics", topics]))
```
### Technical Analysis
The executable publish mode stages the entire target directory with `git add .`, commits it, creates a public GitHub repository, and pushes the commit. The publication gate calls `validate_dir`, but that validator does not perform secret detection or enforce an explicit allowlist of files.
The same workflow invokes `npm publish` and `clawhub publish` without first requiring a successful package-content inspection. Although npm may honor `.npmignore`, `.gitignore`, and the `files` field, the guard does not ensure that these controls exist or exclude sensitive files.
This creates a least-privilege violation at the data level: the workflow needs to publish a defined release artifact, but instead grants the publication commands access to the entire target tree. Th
...[truncated 1673 chars]
- Remediation
- ## Remediation Suggestions
- Replace `git add .` with an explicit release-file allowlist derived from a reviewed manifest.
- Before any publication, require:
- secret scanning;
- package-content inspection;
- version alignment;
- a review of the exact files and destinations;
- explicit confirmation immediately before execution.
- Use `git status --short` and `git diff --cached --name-only` to display the precise staged set.
- Refuse to publish common sensitive files such as `.env`, private keys, credential files, authentication databases, and unredacted logs.
- Run `npm pack --dry-run --ignore-scripts --json`, validate the returned manifest, and publish the reviewed tarball rather than an unchecked working tree.
- Create repositories as private by default, requiring a separate explicit option for public visibility.
- Add tests demonstrating that unignored sensitive fixtures block publication.