Code Monkey home page Code Monkey logo

security_examples's Introduction

PrestaShop Security Module

About

Module to helps you to understand what kinds of security issues exist and how you can prevent it.

Requirements

A working Prestashop 1.7.5 instance and composer (only for development).

PrestaShop Day Presentation

View presentation: https://docs.google.com/presentation/d/1IePuou2D3g1asvGQm1Ni68VLyyaAYJ5Kth7cWOM2cq4/edit?usp=sharing

Understanding exploits

RCE (Remote Code Execution)

Never execute something you can't control. Prefer whitelist as much as possible, or escape string. For example, if you're using Symfony\Component\Process\Process, use the default method to escape commands:

$process = new Process(
    [
        $this->getParameter('kernel.root_dir') . '/../bin/console',
        'debug:' . $type // This one will be automatically escaped
    ]
);
$process->run();

or escapeshellarg

$process = exec(
    __PS_ROOT_DIR__ . '/bin/console ' . 
    escapeshellarg('debug:' . $type)
);

Xss (Cross Site Scripting)

If you don't care about this, you're completly wrong! A thief can take screenshot of your browser, retrieve all form data, control your webcam, get your cookies, ... And if you're using a CMS, with a little piece of code, can create and admin account without being notify. Get a look at (https://beefproject.com/)[https://beefproject.com/], you'll be surprised.

So, don't be shy, always sanitize data and do not display it directly, use htmlentities, htmlspecialchars, ...

SQL Injection

Like others, never trust something you don't control. With a simple script, an attacker can retrieve or create many thing into your database. Or even try to bruteforce your database password.

found_chars = ''
for i in range(20):
    for c in characters:
        try:
            blind_sql = '?username='+username+'" AND IF(password like BINARY "' + found_chars + c + '%",sleep('+sleepTime+'),null)"'
            r = requests.get(target + blind_sql, timeout=5)
        except requests.exceptions.Timeout:
            found_chars += c
            print 'Found chars in password: ' + found_chars
            break

Watch out with rights you give to your database user.

LFI (Local File Include)

Same as previous, use whitelist, identifier to request a file instead of its real name. Prefer http://website.com/download/files/2934 or http://website.com/download/files/my-file than http://website.com/download?file=csv/my-file.csv.

security_examples's People

Contributors

matks avatar pierrerambaud avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

security_examples's Issues

Presentation improvements

  • fix LFI path: missing one ../
  • be compatible php7.1 (trailing commas in function arguments calls)
  • modify LFI to extract parameters file instead of config.define.inc
  • add links "exploit !" in pages to avoid URL copy-paste + token warning

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.