Skip to content

Security: Prevent Fork-Based npm Publishes and Add CODEOWNERS#16

Merged
JeremyDev87 merged 2 commits into
masterfrom
security/15
Dec 17, 2025
Merged

Security: Prevent Fork-Based npm Publishes and Add CODEOWNERS#16
JeremyDev87 merged 2 commits into
masterfrom
security/15

Conversation

@JeremyDev87

Copy link
Copy Markdown
Owner

Security: Prevent Fork-Based npm Publishes and Add CODEOWNERS

📋 Summary

Implements security measures to prevent unauthorized npm package publishing from forks and external contributors. Adds repository checks to canary/dev workflows and comprehensive CODEOWNERS rules for critical security-sensitive paths.

Closes #15

🎯 Problem

Security Risk

As an open source project, Codingbuddy was vulnerable to unauthorized npm package publishing:

  1. Fork-Based Attacks: External contributors could fork the repository, modify workflows, and trigger npm publishes from their forks
  2. No Code Review Requirements: Critical files (workflows, source code, AI rules) could be modified without owner review
  3. Automatic Publishing: dev and canary workflows published to npm without repository ownership verification

Threat Scenarios

  • Malicious code injection via PR → automatic npm publish
  • Workflow manipulation to exfiltrate secrets
  • Supply chain attacks through compromised dependencies

✨ Solution

1. Repository Ownership Checks

Added if conditions to canary and dev workflows to only allow publishing from the main repository:

jobs:
  publish-canary:
    if: github.repository == 'JeremyDev87/codingbuddy'
    # ... rest of job

  publish-dev:
    if: github.repository == 'JeremyDev87/codingbuddy'
    # ... rest of job

Impact: Prevents forks and external repositories from triggering npm publishes.

2. CODEOWNERS Configuration

Created comprehensive .github/CODEOWNERS file with detailed rules:

  • Default owner: @JeremyDev87 for all files
  • Critical paths requiring review:
    • .github/ - GitHub workflows (security-sensitive)
    • mcp-server/ - MCP Server source code
    • .ai-rules/ - AI rules (included in npm package)
    • scripts/ - Build/deployment scripts
    • package.json files - Package configuration

Impact: Ensures all critical changes require code owner approval before merge.

3. Workflow Naming Updates

Updated workflow names for consistency:

  • codebuddy-canarycodingbuddy-canary
  • codebuddy-devcodingbuddy-dev
  • codebuddy-releasecodingbuddy-release

📊 Files Changed

  • Modified Files (4):
    • .github/CODEOWNERS (+22 lines, -1 line)
    • .github/workflows/canary.yml (+2, -2)
    • .github/workflows/dev.yml (+2, -2)
    • .github/workflows/release.yml (+1, -1)

Total: 4 files changed, +28 insertions, -6 deletions

✅ Benefits

Security Improvements

Risk Before After
Malicious code merge High Low (requires owner review)
Unauthorized npm publish High Low (restricted to owner branches)
Workflow manipulation Medium Low (CODEOWNERS protection)

Key Protections

  1. Fork Protection: Prevents npm publishes from forked repositories
  2. Code Review: Requires owner approval for critical file changes
  3. Audit Trail: CODEOWNERS provides clear ownership and review requirements
  4. Defense in Depth: Multiple layers of security (workflow checks + CODEOWNERS)

🧪 Testing

  • Workflow syntax validated
  • CODEOWNERS syntax validated
  • Repository condition logic verified
  • Test: Fork push should NOT trigger npm publish (manual test)
  • Test: Main repo push should trigger npm publish (manual test)
  • Test: CODEOWNERS review requirement works (requires GitHub settings)

Issues

close #15

@JeremyDev87 JeremyDev87 self-assigned this Dec 17, 2025
- Add repository checks to canary/dev workflows
- Add detailed CODEOWNERS rules for security-critical paths
- Update workflow names: codebuddy-* → codingbuddy-*

Prevents unauthorized package publishes from forks.

close #15
- Update package names, CLI binary, and environment variables
- Update all documentation references
- Breaking: CLI command and env var changed
@JeremyDev87 JeremyDev87 marked this pull request as ready for review December 17, 2025 10:24
@JeremyDev87 JeremyDev87 merged commit de283fa into master Dec 17, 2025
2 checks passed
@JeremyDev87 JeremyDev87 deleted the security/15 branch December 21, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secure npm Publishing Workflow for Open Source Project

2 participants