Web security Related (v): SQL injection (SQL injection)

Source: Internet
Author: User
Tags sql injection sql injection attack

Brief introduction

The SQL injection attack refers to the introduction of a special input as a parameter to the Web application, which is mostly a combination of SQL syntax, the execution of SQL statements to perform the actions of the attacker, the main reason is that the program does not carefully filter the user input data, resulting in illegal data intrusion system.

According to the relevant technology principle, SQL injection can be divided into platform layer injection and Code layer injection. The former is caused by an insecure database configuration or a vulnerability to a database platform, which is mainly due to the fact that the programmer has not carefully filtered the input, thus executing the illegal data query. Based on this, the cause of SQL injection usually manifests in the following aspects:

1. Inappropriate types of treatment;

2. Insecure database configuration;

3. Unreasonable query set processing;

4. Improper handling of errors;

5. The escape character processing is not appropriate;

6. Multiple submissions are improperly handled.

Situational Analysis

There are many articles about SQL injection in the garden, here I will not repeat the writing, find a well-written article, here directly provide a portal

  

Prevent SQL injection

1. Never trust the user's input. The user's input can be verified by regular expressions, or by limiting the length, by converting the single quotation mark and the double "-".

2. Never use dynamically assembled SQL, either using parameterized SQL or directly using stored procedures for data query access. (Do not spell SQL, use parameterization)

3. Never use a database connection with administrator rights, and use a separate limited database connection for each app. (Assign reasonable database operation permissions to the program)

4. Do not store confidential information directly, encrypt or hash out passwords and sensitive information. (Sensitive information encryption)

5. The exception information applied should give as few hints as possible, preferably using a custom error message to wrap the original error message.

Web security Related (v): SQL injection (SQL injection)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.