sql-injection

SQL Injection Method

一曲冷凌霜 提交于 2019-12-02 11:05:11
The Injection Procedures are : SELECT UserId, Name, Password FROM Users WHERE UserId = 105 or 1=1; But, My Question Is how the injection query is working in the sql? its when you have your query as string in your code, something like this Query = "SELECT UserId, Name, Password FROM Users WHERE UserId = '" + sUserID + "'" So you pass sUserID = "ABC' OR 1=1;" this will be translated like SELECT UserId, Name, Password FROM Users WHERE UserId = 'ABC' OR 1=1 Since the condition 1=1 is always true , adding it at the end of a WHERE statement renders it irrelevant, and always true , as if the WHERE

Is SQL injection possible even on a prepared statement

人盡茶涼 提交于 2019-12-02 10:43:05
问题 I read many articles on Stack Overflow regarding how SQL injection can be prevented by using prepared statements But is there any way to do SQL injection even on prepared statements or is it 100% safe? Below is my java code String query = "SELECT * FROM Users WHERE username=? and password=?"; ps=con.prepareStatement(query); ps.setString(1,username); ps.setString(2,password); rs = ps.executeQuery(); status = rs.next(); if(status==true){ ..... }else{ .... } I tried some sql injection queries

in general, in javascript, isn't using innerHTML an [in]security issue?

非 Y 不嫁゛ 提交于 2019-12-02 09:40:00
with the DOM and cool new tools such as reactjs , should innerHTML ever be used in a javascript program? using it is a lot like opening oneself to an SQL injection attack, but here it's a cross-site scripting etc. everything needs to be examined and scrubbed before it's used. seems to me innerHTML has the same security issues as eval() and should be avoided for [in]security reasons. (also aesthetically, but that's just me.) Yes, innerHTML is often misused and a very common source of client-side HTML-injection (DOM-XSS) security holes. It's usually better to use object-style creation methods,

Explain how order clause can be exploited in Rails

Deadly 提交于 2019-12-02 09:06:58
I am having difficulty understanding how this section from this website on Rails SQL Injections works. Taking advantage of SQL injection in ORDER BY clauses is tricky, but a CASE statement can be used to test other fields, switching the sort column for true or false. While it can take many queries, an attacker can determine the value of the field. Can someone explain? The bit where they say "switching the sort column for true or false" is the one that is hard to understand because I don't get how that would enable an attacker to reveal the value of another field. If you are trying to determine

Is it possible to do sql injection with stored procedures?

孤人 提交于 2019-12-02 09:04:20
I saw some similar question, none about mysql... Is there any way to do a sql injection into a SP? How do I protect from this on the SP level? In other words, can the Query strucutre, inside a SP can be modified in any way by an incoming parameter? If I send to a stored procedure the parameter "1;DELETE FROM users;--" and the query is: select * from T where = @p SQL injection is, basically, adding extra code to the query. The attack itself occurs because the server parses the input data as SQL code and executes it accordingly. You cannot protect from it on the SP level, because when the

PHP protecting itself from SQL injections?

非 Y 不嫁゛ 提交于 2019-12-02 08:03:10
When I send ");-- from an input field to my localhost PHP server, it AUTOMATICALLY converts it to \");-- It seems great, except that I don't know how trustworthy this behavior is. Although it seems to avoid SQL injections, my development environment is not the same as the production environment and I'm afraid that the production environment may not have this sort of protection automatically activated... Why does PHP does this(convert the input without having to use mysql_real_escape_string )? Does it always do it or only with certain extensions? Is it safe to rely on this behavior to prevent

Preventing code injection without limiting user input? [closed]

▼魔方 西西 提交于 2019-12-02 08:02:39
Ok, so I am aware of methods of input sanitization/checking such as using a whitelist, blacklist, mysqli_escape (or whatever it is in PHP), but say you have a site where, for some reason, instead of having users upload code (HTML, Javascript, C, etc.) inside of a file, they submit snippets directly. However, like any good web admin, you don't want to allow SQL or other types of code injection. As I understand it, using something like mysql_escape will escape all special characters, keywords, etc., so we're covered there. However, what about HTML, Javascript, PHP, and other code? My thinking is

Practices for getting information from $_GET/$_POST and saving it to a database?

…衆ロ難τιáo~ 提交于 2019-12-02 07:24:06
What are today's best practises when it comes to getting information from a get/post and saving information to a database? Is data still escaped like it used to or are there additional practises? Also, where can HTMLPurifier fit in this? I'm currently using it to filter rich text. Never Save data from GET to db. Never ever save data from GET, even if you are doing sufficient validation and escaping. GET is not supposed to change information on server. Before changing anything on server (DB or Server File) check if request is POST or PUT or DELETE as applicable POST is supposed to change state

Improving a function that UPSERTs based on an input array

依然范特西╮ 提交于 2019-12-02 07:04:40
I am hoping to get some help improving a method for UPSERTing rows passed in as an array. I'm on Postgres 11.4 with deployment on RDS. I'm got a lot of tables to sort out, but am starting with a simple table for experimentation: BEGIN; DROP TABLE IF EXISTS "data"."item" CASCADE; CREATE TABLE IF NOT EXISTS "data"."item" ( "id" uuid NOT NULL DEFAULT NULL, "marked_for_deletion" boolean NOT NULL DEFAULT false, "name_" citext NOT NULL DEFAULT NULL, CONSTRAINT item_id_pkey PRIMARY KEY ("id") ); CREATE INDEX item_marked_for_deletion_ix_bgin ON "data"."item" USING GIN("marked_for_deletion") WHERE

SQL Injection in .NET

别说谁变了你拦得住时间么 提交于 2019-12-02 06:26:59
Hi I was wondering if anyone knew of some good websites detailing prevention for SQL injection for .NET web applications. Any resources would be greatly appricated, thank you. I think that, if you google a bit on 'preventing sql injection in .NET', you'll find lots of good resources. :) Anyway, one very important thing, is to not use string-concatenation in order to build your queries. Instead, use parametrized queries. ADO.NET allows to do this, in a very easy way: string sql = "SELECT * FROM Persons WHERE Persons.Lastname LIKE @p_Name"; SqlCommand cmd = new SqlCommand (sql); cmd.Parameters