Security

What Simple does by itself, what is left to you and the web server, and where the secrets are.

Built in

  • Forms. Every POST, on the site and in the admin, carries the visitor's token, and a request without it is refused with 422; the sign-in form sends the visitor back with an error instead. When the browser sends Origin, it must be the site's own host. Deleting, moving and switching on are accepted only by POST.
  • Sign-in. Passwords are stored as hashes from PHP's password_hash(). Five failed sign-ins for one login from one IP address lock that login for that address; twenty from one address lock the address; failures count for 15 minutes. A switched-off user can't sign in. After sign-in the visitor returns only to an address of the same site.
  • Passwords by link. No password is ever sent by mail. A new user and a user who forgot the password get a link that works once, for an hour; the database keeps only a SHA-256 hash of it. The password-reset form answers the same for any address and sends at most one letter per address in 5 minutes. Setting a password ends all of the user's sessions. In the profile, a new password or e-mail needs the current password.
  • Bots. The registration form has a hidden trap field and turns away a form sent sooner than 3 seconds after it was shown. There is no CAPTCHA.
  • Sessions and cookies. A session starts only at sign-in, with a random identifier, and sign-out deletes it. Cookies set by the server are SameSite=Lax and, on HTTPS, Secure; the session cookie NRGNSID and the token's cookie are also HttpOnly.
  • Output. XSLT escapes what it prints. The owner's HTML — texts and page descriptions — is printed as HTML in a few places, each marked in the code, and the repository's test tests/xslt-escaping.php fails on an unmarked one. The admin's grids, page tree and forms show data as text.
  • Uploads. Only users with full rights upload files. Files the web server could run as programs — php and its variants, phtml, phar, cgi, fcgi, pl, py, sh, .htaccess, .htpasswd — are refused. The resizer works only with JPEG, PNG, GIF and WebP files inside uploads/ and answers 404 to anything else.
  • The admin. /admin/ is open only to the group «Администратор» (Administrator); edit mode, the admin toolbar and the editor's windows need full rights. The installer creates the first administrator with the password you give it — there are no default passwords. Demo users exist only after setup demo, and setup check fails while they are there.
  • The address. Links, letters — password links too — and redirects take the site's address from the configuration, never from the request's Host header.

Up to you and the web server

  • HTTPS. Simple never redirects to HTTPS and sends no Strict-Transport-Security. Redirect HTTP to HTTPS and send HSTS from the web server.
  • Headers. Simple sends no Content-Security-Policy, X-Frame-Options, X-Content-Type-Options or Referrer-Policy; add them in the web server. Every page has an inline import map and an inline module script, so a Content-Security-Policy has to allow inline scripts.
  • Debug mode off. With site.debug on, error pages show server paths and anyone can open a page's XML with ?debug. Keep it 0 on a site on the internet; setup check fails while it is on.
  • PHP files. The web server must run .php files through PHP and never serve them as text: web/system.config.php is the configuration with the database password. Keep private/ outside the document root.
  • Editors are trusted. The HTML of a text is saved as the editor sends it, scripts included, and uploaded files of any type that is not refused — HTML and SVG too — are served from the site's own address. Give full rights only to people you trust.
  • Behind a reverse proxy the sign-in limits see the proxy's address, not the visitor's: X-Forwarded-For is ignored on purpose. Let the web server pass the visitor's address to PHP as REMOTE_ADDR — in nginx, with the realip module.

Where the secrets are

  • The database password and the SMTP password are only in the site's configuration, configs/system.config.<host>.php: readable by its owner only, ignored by git, linked from web/system.config.php.
  • The administrator's password for the repository's tests is only in tests/local.php, also readable by its owner only and ignored by git.
  • The installer never takes passwords as options: it reads ENERGINE_DB_PASSWORD and ENERGINE_ADMIN_PASSWORD, or asks for them without echo.
  • The repository's pre-commit hook — git config core.hooksPath .githooks in each clone — refuses a commit that contains the database password or the test administrator's password. It does not look for the SMTP password.
  • git clean -fdx and git stash --all in the repository delete or hide the configuration and tests/local.php.
  • Keep out of web/: the owner's manual from setup manual --out and a static robots.txt. Delete the old resizer's web/resizer/timthumb-config.php.

Reporting a vulnerability

Report it privately, as described in Security on the project page.