fix: Add connection string validation and prevent credential exposure (fixes #37) #65
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
This PR addresses issue #37 by implementing connection string validation and fixing a HIGH severity credential exposure vulnerability in
NewTypeProviderWithConnection.Changes
1. Connection String Length Validation
MaxConnectionStringLength = 1000constant2. CRITICAL: Fix Credential Exposure Vulnerability (HIGH Severity)
Location:
pg/provider.go:60Before (vulnerable):
After (secure):
Why this is critical:
%wpropagates these sensitive details to logs, monitoring systems, and error messages3. Comprehensive Security Test Suite
New file:
pg/provider_connection_security_test.goTests include:
TestConnectionStringLengthValidation- Validates 1000 char limit enforcementTestMalformedConnectionStringsNoCredentialExposure- Verifies no credential leakageTestValidConnectionWithPostgreSQL17- Ensures backward compatibilityTestInvalidConnectionFormats- Tests various invalid input formatsTestConnectionStringSecurityProperties- Comprehensive security property checksTestConnectionStringLengthConstant- Validates constant value is reasonableAll tests pass with PostgreSQL 17 testcontainers.
Security Impact
Vulnerabilities Fixed
Standards Compliance
Research & Evidence
Connection String Limits
Real-World CVE Examples
pgx Library Issues
Testing
make testAll tests pass including:
Coverage: 90.6% of statements
Backward Compatibility
✅ Fully backward compatible
pgxpool.ParseConfigReferences
Closes #37
🤖 Generated with Claude Code