Questions about website security (XSS, SQL, etc)

Source: Internet
Author: User
Questions about website security (XSS, SQL, etc.) does a website need to consider security issues during development?

Except for server security, is it possible to filter dangerous strings for uploads and forms? XSS SQL




Reply to discussion (solution)

Special characters for xss SQL injection cross-origin attacks

This is easy.

2. input verification and output display
2.1 Command Injection
2.2 XSS
2.3 file inclusion
Code injection 2.4
2.5 SQL injection
2.6 XPath injection
2.7 HTTP response splitting
2.8 file management
2.9 file Upload
2.10 variable overwrite
2.11 dynamic functions
3. session Security
3.1 HTTPOnly settings
3.2 domain settings
3.3 path settings
3.4 cookie duration
3.5 secure settings
3.6 Fixed session
3.7 CSRF
4. Encryption
4.1 plaintext storage password

Weak password encryption 4.2
4.3 passwords are stored in files that attackers can access.
5. authentication and authorization
5.1 User Authentication
5.2 unauthenticated call of functions or files
5.3 Password hard encoding
6. random functions
6.1 rand ()
6.2 mt_srand () and mt_rand ()
7. special characters and multi-byte encoding
7.1 multi-byte encoding
8. PHP dangerous functions
8.1 buffer overflow
8.2 session_destroy () file deletion vulnerability
8.3 unset ()-zend_hash_del_key_or_index vulnerability
9. information leakage
9.1 phpinfo
10. PHP environment
10.1 open_basedir settings
10.2 set allow_url_fopen
10.3 set allow_url_include
10.4 safe_mode_exec_dir settings
10.5 magic_quote_gpc settings
10.6 register_globals settings
10.7 safe_mode settings
10.8 session_use_trans_sid settings
10.9 display_errors settings
10.10 expose_php settings

Command injection
PHP can use the following functions to execute system commands: system, exec, passthru, ", shell_exec, popen, proc_open, and pcntl_exec.
By searching for these functions in all program files, we can determine whether the function parameters will change due to external submissions and check whether these parameters have been safely processed.
Defense methods:
Use a user-defined function or function library to replace the functions of external commands
Use the escapeshellarg function to process command parameters
Use safe_mode_exec_dir to specify the path of the executable file

XSS
Reflected cross-site variables are often processed after they are submitted by the user, and are directly output to the client. stored cross-site variables are often processed after they are submitted by the user, stored in the database, and then read the information from the database and output it to the client. Output functions are often used: echo, print, printf, vprintf, <% = $ test %>
For cross-site reflection, because the output is immediately displayed to the client, check whether the variable is immediately displayed after the client submits the variable on the current php page, whether the variables have been checked for security during this process.
For the storage-type cross-site, check whether the variables have passed the security check during the input and output of the input variables.
Defense methods:
If the input data only contains letters and numbers, any special characters should be blocked.
The entered data is strictly matched by the line, such as the Mail format. the user name can only contain English letters, Chinese characters, underscores, and hyphens.
Encode the output in HTML format
<
>
((
))
##
&&
""
''
'% 60

File inclusion
PHP may contain functions including include, include_once, require, require_once, show_source, highlight_file, readfile, file_get_contents, fopen, and nt> file.
Defense methods:
Accurately match the input data, for example, determining the language en based on the value of the variable. php, cn. php, then the two files are placed in the same directory 'language /'. $ _ POST ['Lang ']. '. php ', check whether the submitted data is en or cn is the strictest, and check whether it only contains letters.
Filter the/,..., and other characters in the parameter.

Code injection
PHP may have code injection functions: eval, preg_replace +/e, assert, call_user_func, call_user_func_array, create_function
Find the places where these functions are used in the program, and check whether the submission variables are controllable and whether input verification is performed.
Defense methods:
Exact match of input data
Filter executable functions by whitelist

SQL injection
Because SQL injection is required to operate the database, it generally finds keywords of SQL statements: insert, delete, update, and select to check whether the passed variable parameters are controllable and whether they have been safely processed.
Defense methods:
Use parameterized query

For more details, see here: http://www.sectop.com /? P = 111

The answer from the upstairs is tough.
In my opinion, uploading, form filtering, and mysql escape (or PDO interface) can all reach the security level.
It is difficult to defend against server attacks. Operating system (continuously patching), apahce (potential vulnerabilities), php (upgrade to the latest version), server port (disable some port numbers), FTP (permission and password security ), SSH (port number, password )......

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.