Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2026-08-10 - [Fix SQL LIKE Wildcard Injection in Profile Lookup]
**Vulnerability:** Unescaped wildcard characters in the `did` input for the `LIKE '%:' || $1` clause inside `get_profile`.
**Learning:** The SQL `LIKE` clause doesn't automatically escape '%' and '_' even if they are passed as bound parameters via sqlx. This can lead to wildcard injection attacks and unexpected query matches.
**Prevention:** Whenever user input is dynamically included within a `LIKE` condition, explicitly escape '%', '_', and '\' characters in Rust, and use `ESCAPE '\\'` explicitly within the query.
4 changes: 3 additions & 1 deletion crates/gitlawb-node/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3511,12 +3511,14 @@ impl Db {
}

pub async fn get_profile(&self, did: &str) -> Result<Option<ProfileRecord>> {
let escaped_did = did.replace('\\', "\\\\").replace('%', "\\%").replace('_', "\\_");
let row = sqlx::query(
"SELECT did, display_name, bio, avatar_url, website, socials, profile_cid, created_at, updated_at
FROM agent_profiles
WHERE did = $1 OR did LIKE '%:' || $1",
WHERE did = $1 OR did LIKE '%:' || $2 ESCAPE '\\'",
)
.bind(did)
.bind(&escaped_did)
.fetch_optional(&self.pool)
.await?;

Expand Down