codeant-ai-for-open-source[bot] commented on code in PR #42603:
URL: https://github.com/apache/superset/pull/42603#discussion_r3701029341
##########
superset/views/database/validators.py:
##########
@@ -52,5 +52,10 @@ def schema_allows_file_upload(database: Database, schema:
Optional[str]) -> bool
if not database.allow_file_upload:
return False
if schemas := database.get_schema_access_for_file_upload():
- return schema in schemas
+ # Databases may report schema names in uppercase while the allow-list
+ # is inputted manually, so compare case-insensitively — mirroring the
+ # ``upload_allowed`` filtering of the database schemas endpoint.
+ return schema is not None and schema.lower() in {
+ allowed.lower() for allowed in schemas
+ }
Review Comment:
**Suggestion:** Case-folding the schema for authorization is unsafe for
engines that support quoted, case-sensitive identifiers. For example, an
allow-list containing `public` accepts a request for `PUBLIC`, but SQLAlchemy
can emit the latter as the distinct quoted schema `"PUBLIC"`, allowing an
upload outside the configured schema. Authorization must use the engine's
identifier normalization rules or compare the actual physical schema name
exactly. [security]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ Upload authorization can include an unintended PostgreSQL schema.
- ❌ Data may be written outside configured schema boundaries.
- ⚠️ Requires case-distinct schemas and an allow-list.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=9a506e086e434646bc2ae90ef7055ef4&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=9a506e086e434646bc2ae90ef7055ef4&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/views/database/validators.py
**Line:** 58:60
**Comment:**
*Security: Case-folding the schema for authorization is unsafe for
engines that support quoted, case-sensitive identifiers. For example, an
allow-list containing `public` accepts a request for `PUBLIC`, but SQLAlchemy
can emit the latter as the distinct quoted schema `"PUBLIC"`, allowing an
upload outside the configured schema. Authorization must use the engine's
identifier normalization rules or compare the actual physical schema name
exactly.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42603&comment_hash=9044339c4bf684c8ecdc4401eb4211c99f236da5df8b9291bafd5394fb70b2ed&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42603&comment_hash=9044339c4bf684c8ecdc4401eb4211c99f236da5df8b9291bafd5394fb70b2ed&reaction=dislike'>👎</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]