Back to skill

Security audit

Merge Duplicate Companies

Security checks for vulnerabilities and agentic risk

Overview

This skill performs a disclosed HubSpot duplicate-company audit using a read-only token and local CSV exports, with manual-only merge guidance.

Install only in an environment where the HubSpot private app token is scoped to crm.objects.companies.read, run it from a trusted workspace, and keep the generated CSVs out of shared folders and repositories. Review every merge manually because HubSpot company merges are irreversible.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (2)

T08 · Insecure Dependencies

Warning
Location
scripts/before.py:2
Finding

Unpinned Third-Party Dependencies Permit Unreviewed Package Changes

Content
View full analysis

Vulnerability Details

File Location: scripts/before.py:2-6
Vulnerability Type: Unpinned third-party dependencies and insufficient supply-chain integrity controls
Risk Level: Medium

Technical Analysis

The script declares dependencies using minimum-version constraints rather than exact, reviewed versions:

python
# /// script
# requires-python = ">=3.10"
# dependencies = [
#   "requests>=2.31",
#   "python-dotenv>=1.0",
# ]
# ///

The package setup instructions in SKILL.md:317-320 likewise install dependencies without exact versions or hashes:

bash
uv init hubspot-cleanup
cd hubspot-cleanup
uv add requests python-dotenv

No reviewed lockfile or package hashes are included in the project. Consequently, separate installations may resolve different releases, including future versions that were not reviewed during this audit.

Both dependencies execute Python code in the same process as the Skill. A compromised or malicious resolved release could therefore read HUBSPOT_ACCESS_TOKEN, access the CRM data returned by HubSpot, modify generated audit files, or perform additional actions with the privileges of the user running the Skill.

This finding does not establish that the currently named packages are malicious. The vulnerability is the absence of reproducible dependency resolution and integrity verification.

Attack Path

  1. An attacker compromises a future release or distribution channel for one of the declared dependencies.
  2. A user installs or executes the Skill in an environment without a previously reviewed lockfile.
  3. The >= constraint resolves the compromised release.
  4. Malicious package installation or import-time code executes inside the Skill process.
  5. The package reads the HubSpot token from the environment or intercepts CRM responses.
  6. The package exfiltrates credentials or CRM data, alters output, or performs other actions available to the local user.

Impact Assessment

Successful exploitation c ...[truncated 464 chars]

Remediation
View remediation

Remediation Suggestions

  1. Resolve dependencies once in a controlled environment and commit a reviewed uv.lock.
  2. Pin exact package versions rather than relying solely on lower bounds.
  3. Enforce locked installations, such as running uv with its frozen or locked mode in automated execution.
  4. Where supported, verify downloaded distributions using cryptographic hashes.
  5. Review dependency updates before changing the lockfile and use automated vulnerability scanning.
  6. Restrict package indexes to approved HTTPS repositories and disable untrusted supplemental indexes.
  7. Run the Skill in a minimally privileged environment with access only to the required token and output directory.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/before.py:124
Finding

Sensitive CRM Metadata Is Exported to Plaintext Files Without Explicit Access Controls

Content
View full analysis

Vulnerability Details

File Location: scripts/before.py:124-165
Vulnerability Type: Plaintext storage of sensitive business data with inherited filesystem permissions
Risk Level: Medium

Technical Analysis

The Skill creates a predictable output directory and writes CRM metadata to ordinary plaintext CSV files:

python
# --- Step 4: Save CSVs ---
print("Step 4: Saving audit CSVs...")

output_dir = os.path.join(os.path.dirname(__file__), "..", "data")
os.makedirs(output_dir, exist_ok=True)

# Domain duplicates CSV
domain_csv = os.path.join(output_dir, "duplicate-companies-by-domain.csv")
with open(domain_csv, "w", newline="") as f:
    writer = csv.DictWriter(f, fieldnames=["domain", "duplicate_count", "id", "name",
              "lifecycle_stage", "associated_contacts", "associated_deals", "owner_id", "createdate"])
    writer.writeheader()
    for domain, companies in sorted_domains:
        for c in companies:
            writer.writerow({
                "domain": domain,
                "duplicate_count": len(companies),
                **{k: c[k] for k in ["id", "name", "lifecycle_stage", "associated_contacts",
                                      "associated_deals", "owner_id", "createdate"]},
            })

print(f"  Domain duplicates: {domain_csv}")

# Name duplicates CSV
name_csv = os.path.join(output_dir, "duplicate-companies-by-name.csv")
with open(name_csv, "w", newline="") as f:
    writer = csv.DictWriter(f, fieldnames=["duplicate_name", "duplicate_count", "id", "name",
              "domain", "lifecycle_stage", "associated_contacts", "associated_deals", "owner_id", "createdate"])
    writer.writeheader()
    for name_lower, companies in sorted_names:
        for c in companies:
            writer.writerow({
                "duplicate_name": name_lower,
                "duplicate_count": len(companies),
                **{k: c[k] for k in ["id", "name", "domain", "lifecycle_stage",
                                      "ass
...[truncated 1874 chars]
Remediation
View remediation

Remediation Suggestions

  1. Create the output directory with owner-only permissions and verify permissions if it already exists.
  2. Create files atomically with restrictive mode 0600 rather than relying solely on the process umask.
  3. Add the generated data/ directory and CSV filenames to .gitignore.
  4. Display a clear notice identifying the fields that will be exported and obtain confirmation before writing them.
  5. Allow the user to select a secure output location instead of always using a predictable project-relative path.
  6. Avoid overwriting prior exports silently; use unique filenames or require explicit confirmation.
  7. Document retention and secure-deletion procedures for the audit files.
  8. Consider encrypted output when files must be stored or transferred outside a controlled local environment.
  9. Minimize exported fields where possible, such as omitting owner IDs or creation dates when they are not needed for a particular review.
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • 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
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (5)

Tainted flow: 'headers' from os.environ (line 26, credential/environment) → requests.get (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/before.py (reported line 52)May include surrounding context.

python
if after:
        params["after"] = after

    resp = requests.get(f"{BASE}/crm/v3/objects/companies", headers=headers, params=params)
    if resp.status_code != 200:
        print(f"  Stopped at {len(all_companies)} (status {resp.status_code})")
        break

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 · SKILL.md (reported line 22)May include surrounding context.

md
## Prerequisites

- A HubSpot private app access token with `crm.objects.companies.read` scope
- Python 3.10+ with `uv` for package management
- A `.env` file containing `HUBSPOT_ACCESS_TOKEN`
- Super Admin permissions for merging in the HubSpot UI

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/before.py (reported line 21)May include surrounding context.

python
from collections import defaultdict
from dotenv import load_dotenv

load_dotenv(os.path.join(os.path.dirname(__file__), "..", ".env"))

TOKEN = os.environ["HUBSPOT_ACCESS_TOKEN"]
BASE = "https://api.hubapi.com"

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill contains executable guidance that reads an environment variable, performs outbound network requests to HubSpot, and writes CSV files locally, but it does not declare any explicit tool/permission scope. That mismatch weakens least-privilege controls and transparency, making it easier for an agent runtime to grant broader capabilities than reviewers expect.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The script exports CRM company data, including names, domains, owner IDs, lifecycle stage, and association counts, into local CSV files without an explicit sensitivity warning, consent checkpoint, or file-permission hardening. In enterprise environments, these exports can persist on disk, be synced to cloud storage, or be accessed by other local users, creating unnecessary exposure of potentially sensitive business data.

Content

No source excerpt is available for this finding.