• Tidak ada hasil yang ditemukan

Part 10 Internal Security

N/A
N/A
Protected

Academic year: 2017

Membagikan "Part 10 Internal Security"

Copied!
9
0
0

Teks penuh

(1)

WEB SECURITY

CodeIgniter’s internal security features Source : manual_guide ci

IKB112312

(2)

URI Security

CodeIgniter is fairly restrictive regarding which characters it allows in your

URI strings in order to help minimize the possibility that malicious data

can be passed to your application. URIs may only contain the following:

Alpha-numeric text (latin characters only)

(3)

Register_globals

(4)

display_errors

Setting CodeIgniter‟s ENVIRONMENT constant in index.php to a value

of ‘production’ will turn off these errors. In development mode, it is

(5)

XSS Filtering

CodeIgniter comes with a Cross Site Scripting filter. This filter looks for commonly used techniques to embed malicious JavaScript into your data, or other types of code that attempt to hijack cookies or do other malicious things.

To filter data through the XSS filter use the xss_clean() method :

(6)

Validate input data

Validate the data to ensure it conforms to the correct type, length, size, etc. CodeIgniter has a Form Validation Library that assists you in validating, filtering, and prepping your data.

$this->form_validation->set_rules(

'username', 'Username',

'required|min_length[5]|max_length[12]|is_unique[users.username]', array(

'required' => 'You have not provided %s.',

'is_unique' => 'This %s already exists.'

) );

$this->form_validation->set_rules('password', 'Password', 'required');

$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required|matches[password]');

(7)

Escape all data before database insertion

Never insert information into your database without escaping it.

Example :

(8)

Hide your files

Another good security practice is to only leave your index.php and “assets”

(e.g. .js, css and image files) under your server‟s webroot directory (most

commonly named “htdocs/”). These are the only files that you would need to

(9)

Password handling

 DO NOT store passwords in plain-text format.

 DO NOT use Base64 or similar encoding for storing passwords.

 DO NOT use weak or broken hashing algorithms like MD5 or SHA1.

$options = [

'cost' => 12,

];

Referensi

Dokumen terkait