Skip to content

feat: add user search helpers#8

Open
Vacbo wants to merge 1 commit into
masterfrom
feat/search-v2
Open

feat: add user search helpers#8
Vacbo wants to merge 1 commit into
masterfrom
feat/search-v2

Conversation

@Vacbo
Copy link
Copy Markdown
Owner

@Vacbo Vacbo commented May 31, 2026

Adds search_users_by_name and count_users_by_status for the user-admin search feature.

@mas-ops-bot
Copy link
Copy Markdown

mas-ops-bot Bot commented May 31, 2026

[ERROR]

SQL Injection Vulnerability: Direct string concatenation of user input into SQL query.

The name parameter is concatenated directly into the LIKE clause without parameterization. An attacker can inject arbitrary SQL by crafting a malicious search term.

Fix: Use SQLAlchemy's parameter binding instead:

query = text("SELECT id, email, full_name FROM \"user\" WHERE full_name LIKE :name")
return session.exec(query, {"name": f"%{name}%"}).all()

Target: backend/app/crud_search.py:12

@mas-ops-bot
Copy link
Copy Markdown

mas-ops-bot Bot commented May 31, 2026

[ERROR]

SQL Injection Vulnerability: String formatting of user-controlled statuses into SQL IN clause.

The statuses list is formatted directly into the query using string interpolation. Malicious status values can break out of the IN clause and inject arbitrary SQL.

Fix: Use parameterized queries with dynamic binding:

placeholders = ",".join([f":status_{i}" for i in range(len(statuses))])
params = {f"status_{i}": s for i, s in enumerate(statuses)}
result = session.exec(
    text(f"SELECT count(*) FROM \"user\" WHERE status IN ({placeholders})"),
    params
)

Also: the bare except: clause on line 24 masks SQL errors. Replace with specific exception handling.

Target: backend/app/crud_search.py:21

@mas-ops-bot
Copy link
Copy Markdown

mas-ops-bot Bot commented May 31, 2026


Summary

This PR introduces two critical SQL injection vulnerabilities in backend/app/crud_search.py:

  1. Line 11–12: Unsanitized user input concatenated directly into a LIKE clause
  2. Line 18–21: String-formatted statuses list inserted into an IN clause without parameterization

The proposed fix plan references unrelated files (api/pipeline/runner.py, graph/pipeline.py) that do not contain these vulnerable functions. Manual intervention is required to implement proper parameterized query fixes using SQLAlchemy's parameter binding mechanism. Detailed corrections have been posted as inline comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant