• Stars
    star
    1,477
  • Rank 31,721 (Top 0.7 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A php.ini scanner for best security practices

Scanner for PHP.ini

Build Status Total Downloads

SensioLabsInsight

The Iniscan is a tool designed to scan the given php.ini file for common security practices and report back results. Currently it is only for use on the command line and reports the results back to the display for both Pass and Fail on each test.

Installation

Using Composer

composer require psecio/iniscan

The only current dependency is the Symfony console.

Global Composer installation

Additionally, you can install it outside of a project with the global functionality Composer provides. From any directory you can use:

$ ./composer.phar global require psecio/iniscan
$ ~/.composer/vendor/bin/iniscan

Using a single Phar file

First make sure you run composer.phar install

curl -LSs https://box-project.github.io/box2/installer.php | php
php box.phar build

This should result in a iniscan.phar file being created in the root folder. Instead of using vendor/bin/iniscan in the examples use ./iniscan.phar instead.

Example

vendor/bin/iniscan scan --path=/path/to/php.ini
Results for /private/etc/php.ini:
============
Status | Severity | PHP Version | Key                      | Description
----------------------------------------------------------------------
PASS   | ERROR    |             | session.use_cookies      | Accepts cookies to manage sessions
PASS   | ERROR    | 4.3.0       | session.use_only_cookies | Must use cookies to manage sessions, don't accept session-ids in a link

1 passing
2 failure(s)

NOTE: When the scan runs, if it cannot find a setting in the php.ini given, it will use ini_get to pull the current setting (possibly the default).

Command line usage

Iniscan offers a few commands for both checking and showing the contents of your php.ini.

Scan

The scan command will be the most used - it runs the rules checks against the given ini file and reports back the results. For example:

vendor/bin/iniscan scan --path=/path/to/php.ini

If the path is omitted, iniscan will try to find it based off the current configuration (a "php -i" call). By default, this reports back both the pass and fail results of the checks. If you'd like to only return the failures, you can use the fail-only argument:

vendor/bin/iniscan scan --path=/path/to/php.ini --fail-only

The scan command will return an exit code based on the results:

  • 0: No errors
  • 1: Failures found

Scan Level Threshold

You can request the only scan for rules that are on or above a threshold:

vendor/bin/iniscan scan --path=/path/to/php.ini --threshold=ERROR

There are 3 levels you can use:

  • WARNING
  • ERROR
  • FATAL (No rules uses that level at the moment)

Show

The show command lists out the contents of your php.ini file with a bit of extra formatting.

vendor/bin/iniscan show --path=/path/to/php.ini

List

The list-tests command shows a listing of the current rules being checked and their related php.ini key.

vendor/bin/iniscan list-tests

Output formats

By default iniscan will output information directly to the console in a human-readable result. You can also specify other output formats that may be easier to parse programatically (like JSON). Use the --format option to change the output:

vendor/bin/iniscan show --path=/path/to/php.ini --format=json

the list-tests command also supports JSON output:

vendor/bin/iniscan list-tests --path=/path/to/php.ini --format=json

NOTE: Currently, only the scan command supports alternate output formats - console, JSON, XML and HTML.

The HTML output option requires an --output option of the directory to write the file:

vendor/bin/iniscan scan --format=html --output=/var/www/output

The result will be written to a file named something like iniscan-output-20131212.html

Contexts

The scanner also supports the concept of "contexts" - environments you may be executing the scanner in. For example, in your development environment, it may be okay to have display_errors on. In production, however, this is a bad idea. The scanner's default assumes you're using it in prod, so it uses the strictest checks unless you tell it otherwise. To do so, use the context command line option:

vendor/bin/iniscan show --path=/path/to/php.ini --context=dev

In this case, we've told it we're running in dev, so anything that specifically mentions "prod" isn't executed.

Deprecated reporting

As the scanner runs, it will compare the configuration key to a list of deprecated items. If the version is at or later than the version defined in the rules, an error will be shown in the output. For example, in the console, you'd see:

WARNING: deprecated configuration items found:
-> register_globals
It's recommended that these settings be removed as they will be removed from future PHP versions.

This is default behavior and does not need to be enabled.

@author Chris Cornutt [email protected]

Bitdeli Badge

More Repositories

1

gatekeeper

Gatekeeper: An Authentication & Authorization Library
PHP
366
star
2

parse

Parse: A Static Security Scanner
PHP
357
star
3

versionscan

A PHP version scanner for reporting possible vulnerabilities
PHP
255
star
4

secure_dotenv

A secure .env handler with encrypted key/value storage
PHP
117
star
5

jwt

A JWT (JSON Web Token) Encoder & Decoder
PHP
110
star
6

propauth

A library for property-based policy evaluation
PHP
59
star
7

invoke

Invoke: Route Authentication/Authorization Management
PHP
36
star
8

canary

Canary: Input Detection and Response
PHP
30
star
9

pwdcheck

A password strength checking utility
PHP
21
star
10

secure-api

Repository for the "Building a Secure API" series on Websec.io
PHP
16
star
11

csrf

CSRF Token Generation Library
PHP
13
star
12

uri

A secure URI generation and validation library
PHP
12
star
13

verify

Framework Agnostic Authentication & Authorization
PHP
11
star
14

protected-env-example

An example (Docker environment) showing the protection of sensitive information from PHP's file read
PHP
10
star
15

rift

A vulnerable application for teaching the basics of web application security
CSS
9
star
16

security-bundle

A bundle of recommended PHP security libraries
8
star
17

validation

A simple little validation library
PHP
7
star
18

dbot

Discord bot platform for PHP
PHP
7
star
19

session-encrypt

An encrypted session handler
6
star
20

fortify

Fortify provides a single, simple interface for handling authentication and authorization
PHP
6
star
21

notch

Notch: A Vulnerable Application
PHP
4
star
22

oauth2-discord

A Discord provider for the League OAuth2 Client
PHP
4
star
23

gatekeeper-ui

A web interface for the Gatekeeper Access Control System
JavaScript
3
star
24

gatekeeper-cli

A command line tool for the Gatekeeper auth framework
PHP
2
star
25

authorize

A comprehensive authorization library (ACL, RBAC, PBAC)
PHP
1
star
26

phpsecinfo

Code for the phpsecinfo.com site
PHP
1
star
27

userappio

An API library for using the UserApp.io Service
PHP
1
star
28

securingphp

Source for the Securing PHP website
PHP
1
star
29

vaultlib

A simple Vault client for PHP
PHP
1
star
30

statext

A PHP static site generator
PHP
1
star