Skip to content

Conversation

@akshayutture-augment
Copy link
Contributor

… vulnerability (#94942)

* disable sql expressions

remove duckdb ref

* Run `make update-workspace`

---------

Co-authored-by: Scott Lepper <[email protected]>
@akshayutture-augment
Copy link
Contributor Author

@claude review this PR

1 similar comment
@akshayutture-augment
Copy link
Contributor Author

@claude review this PR

@claude
Copy link

claude bot commented Nov 20, 2025

Claude finished @akshayutture-augment's task —— View job


PR Review Complete

Tasks

  • Gather context and read changed files
  • Analyze changes for security vulnerabilities
  • Review code quality and best practices
  • Post comprehensive review feedback

🚨 Critical Security Issue

This PR appears to be reverting a critical security fix that was implemented in commit ea71201d to prevent RCE (Remote Code Execution) and LFI (Local File Inclusion) vulnerabilities in SQL Expressions.

Analysis

What This PR Does

This PR is essentially undoing the security patch from October 18, 2024:

  1. Removes dependency removal - Re-adds the dangerous dependencies that were removed:

    • github.com/scottlepp/go-duck and related DuckDB dependencies
  2. Keeps the stub implementation - The pkg/expr/sql/db.go file still has stub methods that return "not implemented" errors, meaning:

    • SQL expressions are still disabled functionally
    • But the dangerous external dependencies are being re-added
  3. Keeps the feature flag check - The enableSqlExpressions() function in pkg/expr/reader.go:194-200 still returns false in all cases, so SQL expressions remain disabled

Security Concerns

Critical Issues:

  1. Reintroducing Attack Surface (go.mod, go.sum, go.work.sum)

    • Re-adds github.com/scottlepp/go-duck v0.1.0 which was removed for security reasons
    • This library enables SQL execution that can lead to RCE/LFI vulnerabilities
    • Even if not actively used, having it in dependencies increases attack surface
  2. Dead Code with Security Implications (pkg/expr/sql/parser.go:23)

    • Line 23 calls NewInMemoryDB() which creates a DB instance
    • Lines 26, 29 attempt to use SQL parsing functionality
    • This code path is currently unreachable due to the feature flag, but:
      • Someone could accidentally enable it
      • The dependencies are present and could be exploited
  3. Confusing Implementation (pkg/expr/reader.go:194-200)

    func enableSqlExpressions(h *ExpressionQueryReader) bool {
        enabled := !h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)
        if enabled {
            return false
        }
        return false
    }
    • This function always returns false regardless of input
    • The logic is confusing: it checks if SQL expressions are disabled, then returns false anyway
    • This suggests incomplete work or a misunderstanding of the intent

Code Quality Issues

  1. Redundant Logic (pkg/expr/reader.go:194-200)

    • The function could be simplified to return false since it never returns true
    • The feature flag check is meaningless
  2. Incomplete Implementation (pkg/expr/sql/db.go)

    • All methods return "not implemented" errors
    • This is a stub that serves no functional purpose
    • If SQL expressions should be disabled, this file shouldn't exist
  3. Inconsistent State

    • The PR keeps the security-motivated stubs but re-adds the dangerous dependencies
    • This is the worst of both worlds: security risk + no functionality

Recommendations

❌ DO NOT MERGE this PR as-is. Here are the options:

Option 1: Keep SQL Expressions Disabled (Recommended)

  • Remove this PR entirely
  • Keep the current security fix from commit ea71201d
  • SQL expressions remain disabled, dependencies stay removed

Option 2: Re-enable SQL Expressions Safely
If there's a legitimate need to re-enable SQL expressions:

  1. Perform a thorough security audit of the go-duck library
  2. Implement proper input sanitization and sandboxing
  3. Add comprehensive security testing
  4. Get security team approval
  5. Document the security risks and mitigations
  6. Fix the enableSqlExpressions() function to actually check the feature flag properly

Option 3: Alternative SQL Implementation

  • Use a different, more secure SQL parsing library
  • Implement query allowlisting/denylisting
  • Run SQL in a heavily sandboxed environment

Questions for the Author

  1. What is the business justification for re-enabling SQL expressions?
  2. Has a security review been conducted?
  3. Why keep the stub implementations while re-adding the dependencies?
  4. Is there awareness that this reverts a critical security fix?

File-by-File Review

  • go.mod, go.sum, go.work.sum: Re-adds dangerous dependencies removed in security fix
  • pkg/expr/reader.go:194-200: Broken logic that always returns false
  • pkg/expr/sql/db.go: Stub implementation with no functionality
  • pkg/expr/sql/parser.go:23: Still attempts to use DuckDB functionality
  • pkg/expr/sql_command.go:96-100: Uses stub DB that will always fail

|

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants