Git Product home page Git Product logo

Comments (2)

luxu1-ms avatar luxu1-ms commented on May 10, 2024

My initial thought is to use brackets for table name, but then concerned that below example will still inject sql db. So I tried prepared statement in PR #138, but it turns out table name cannot be parameter in prepared statement.
sql statement in src code:
SELECT * FROM ${table} WHERE 1=0; ($table is user input)
possible sql injection examples;
SELECT * FROM [table_a]; DROP table table_b --] WHERE 1=0;
Spark also uses sql statement (e.g. in JdbcUtils.scala) to drop / truncate / check existence of a table. tableExists() uses prepared statement to wrap the sql string but without parameters. In my opinion it does not avoid sql injection.

from sql-spark-connector.

luxu1-ms avatar luxu1-ms commented on May 10, 2024

I can inject sql table set dbtable = "test00(Col1 nvarchar(4)); DROP TABLE test1--", then my test1 will be dropped and test00 will be created. (inject the sql string in mssqlCreateTable()).

For now I do not think SQL Injection is a vulnerability in spark mssql connector.

  1. The main point is that user who is creating / dropping / editing a sql table by JDBC must have the credentials already and could just open their own connection.
  2. IMO spark has sql strings which might be vulnerable to sql injection. I think it is better to fix it in spark end.

from sql-spark-connector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.