簡體   English   中英

允許指定列名使其具有潛在的SQL注入風險

[英]Allowing column name to be specified makes it a potential SQL injection risk

有人告訴我這兩種方法“您允許指定列名的事實是(SQL)注入風險”。 甚至是什么意思? 由誰指定? 我該如何解決?

public void tableChanged(TableModelEvent e) {
    int row = e.getFirstRow();
    int col = e.getColumn();
    model = (MyTableModel) e.getSource();
    String stulpPav = model.getColumnName(col);
    Object data = model.getValueAt(row, col);
    Object studId = model.getValueAt(row, 0);
    System.out.println("tableChanded works");
    try {
        new ImportData(stulpPav, data, studId);
        bottomLabel.setText(textForLabel());
    } catch (ClassNotFoundException e1) {
        e1.printStackTrace();
    } catch (SQLException e1) {
        e1.printStackTrace();
    }
}

public class ImportData {    

    public ImportData(String a, Object b, Object c)
            throws ClassNotFoundException, SQLException {
        PreparedStatement prepStmt = null;
        try {
            connection = TableWithBottomLine.getConnection();
            String stulpPav = a;
            String duom = b.toString();
            String studId = c.toString();
            System.out.println(duom);

            String updateString = "update finance.fin " + "set ? = ? " + "where ID = ? "+ ";";
            prepStmt = connection.prepareStatement(updateString);
            prepStmt.setString(1, stulpPav);
            prepStmt.setString(2, duom);
            prepStmt.setString(3, studId);              

        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            if (prepStmt != null)
                prepStmt.close();
            System.out.println("Data was imported to database");
        }  
    }   
}

甚至是什么意思? :)

這意味着,如果更改了字符串,則可以放入SQL代碼以執行其他操作,例如更新密碼或限制對系統的訪問。

由誰指定?

可以訪問列名的任何代碼,僅當用戶有權訪問此字段時,這才是問題。

我該如何解決?

檢查用戶是否確實無法指定此列名,並忽略該消息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM