Skip to content

Security: Connection strings don't URL-encode credentials #21

@bartbeecoders

Description

@bartbeecoders

Summary

In src-tauri/src/db/connections.rs (lines 85-94), database credentials are interpolated directly into connection URLs without URL encoding:

```rust
format!("postgres://{}:{}@{}:{}/{}", self.user, self.password, self.host, self.port, self.database)
```

Risk

Passwords containing @, :, /, ?, #, or % will break the connection URL parser or route credentials to the wrong host. A password like p@ssword would be parsed as user:p with host ssword. Severity is medium — causes connection failures and could theoretically leak credentials to unintended hosts.

Remediation

URL-encode user and password before interpolation:

```rust
use urlencoding::encode;
format!("postgres://{}:{}@{}:{}/{}", encode(&self.user), encode(&self.password), ...)
```

Add the urlencoding crate or use percent_encoding from the url crate (already a transitive dep).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsecuritySecurity vulnerability or hardening

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions