Skip to content

Database Connection String Not Validated #37

@richardwooding

Description

@richardwooding

Summary

NewTypeProviderWithConnection() accepts connection strings without validation.

Location

pg/provider.go:48-58

Issue

Malformed strings could expose information through error messages.

Impact

Medium - Information leakage risk.

Recommendation

func NewTypeProviderWithConnection(ctx context.Context, connStr string) (TypeProvider, error) {
    if len(connStr) > 1000 {
        return nil, errors.New("connection string too long")
    }
    
    pool, err := pgxpool.New(ctx, connStr)
    if err != nil {
        return nil, errors.New("failed to create connection pool")
    }
    
    if err := pool.Ping(ctx); err != nil {
        pool.Close()
        return nil, errors.New("failed to connect to database")
    }
    // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    category::securitySecurity vulnerabilities and hardeningseverity::mediumModerate issues affecting quality or usability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions