Repository navigation
fix(security): harden production configuration and GitHub trust boundaries - #12
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens production environment configuration and locks down GitHub trust boundaries to ensure only verified TechNexusOrg organization repositories (Organization ID 333899669) can participate in the contribution and verifiable credential lifecycle.
Changes
src/lib/env.ts):AUTH_SECRET,GITHUB_CLIENT_ID,GITHUB_CLIENT_SECRET, andGITHUB_WEBHOOK_SECRET.DATABASE_URLin production.INTERNAL_SERVICE_SECRETdedicated to background/sync service authorization.safeCompareusingcrypto.timingSafeEqualto eliminate timing attack vectors.src/lib/db/index.ts):NODE_ENV=production. Throws a fatal, clear configuration error if PostgreSQL connection fails or URL is invalid.src/lib/github/issues.ts,src/lib/projects/approval.ts,src/lib/github/webhooks.ts):github_repo_idandgithub_owner_idto theprojectstable with indexes.src/app/api/webhooks/github/route.ts):X-GitHub-Deliveryheader for pipeline events to preserve delivery idempotency and audit logs.src/app/api/sync/issues/route.ts):AUTH_SECRETto dedicatedINTERNAL_SERVICE_SECRETwith constant-time equality check.drizzle/0005_project_trust_boundary.sqlforgithub_repo_idandgithub_owner_idcolumns and indexes.drizzle/meta/_journal.json.src/lib/env.test.tsto cover production fail-closed rules, placeholder rejection, andsafeCompare.src/lib/projects/approval.test.tsto test repository trust boundaries and approval rejection.src/lib/github/webhooks.test.tsto test spoofed owner IDs.Architecture
Enforces least-privilege trust boundaries at ingress points (webhooks, API sync, and admin approval). Separates user session secret (
AUTH_SECRET) from internal service automation secret (INTERNAL_SERVICE_SECRET).Security Considerations
Database Migrations
drizzle/0005_project_trust_boundary.sqlALTER TABLE projects DROP COLUMN github_repo_id, DROP COLUMN github_owner_id;Testing
npm run lint: passed with 0 errors, 0 warnings.npm run typecheck: passed with 0 errors.npm test: 80 passed across 18 test files (including new security tests).npm run build: production build completed successfully (19 static/dynamic routes).Deployment Considerations
Ensure production environment contains:
AUTH_SECRET(min 32 chars).INTERNAL_SERVICE_SECRET(min 32 chars).DATABASE_URL.Related Issues
Fixes #11