GithubHelp home page GithubHelp logo

pure_php_scratch_security's Introduction

pure_php_scratch_security

covering the fundamental security logics using pure php

file extension to care about

php coded files should be with php extension, otherwise these will not compiled and will be visible for the contents

xss attack

loading the data from the database back should be escape harmful chars relating with xss.
In this sample project, I use htmlspecialchars

password hashing

using the buildin php funtion password_hash and verifying back password_verify . eg. password_hash('password',PASSWORD_DEFAULT,['cost' => 10]);

Hiding dir listing

using .htaccess to forbid the access of viewing our dirs . eg. Options -Indexes

Httponly cookies

store cookies with httponly so that client side can't get any cookies data. Only server side can get . Normally should not store any plain text value cookies.

CSRF

attackers can emit an ajax request to do pretty problematic issues . putting a session token like a middlware can prevent this kind of issues . I generate a session token, adding in form and make conditional statement it matches the token or not after submitting the form . I use bin2hex(random_bytes(int)) for generating the random token . For < php 7 , use openssl_random_pseudo_bytes

SQL Injection

attackers can simply make sql injection attack very easily and vice versa can easily prevent using prepare statement . Example . $connection = $db->prepare("query = :param"). Then execute . $connection->execute([ . 'param' => $value . ]);

Error Reporting

You can control the debugging reports easily in php.ini. If you dont want to manage php.ini. These below two statements can be used . ini_set('display_errors','Off') . error_reporting(0)

pure_php_scratch_security's People

Contributors

hlaingtinhtun avatar

Stargazers

Yauno avatar  avatar Htin Lynn avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.