Notes About Security

Built-in protections

  • The Public Area and the Administration Area of TCExam are physically separated on the filesystem. This allows to add further access restrictions based on the filesystem and the web server, and the application ships .htaccess access controls.
  • To access the various TCExam resources you need a valid account (user/password) and a level equal to or greater than the requested resource level. The level of test takers and Public areas is 1 by default. TCExam also supports RADIUS, LDAP and CAS authentication, as well as custom authentication methods.
  • Passwords are stored using a modern password hashing algorithm.
  • Test takers may access a particular test only if they belong to a group enabled for that test.
  • Test takers may access a particular test only if their IP address is enabled for that test.
  • Test takers may execute a particular test only one time (unless authorized by an administrator, or the test is explicitly marked as repeatable).
  • TCExam may generate a unique test for each user by randomly selecting and ordering questions and alternative answers. This drastically reduces or eliminates the risk of copying between test takers.
  • The test time is kept by the server. At the end of the available time the test is automatically closed.
  • The full activity of the test taker is logged on the server, including statistical data (e.g. reaction time) and security data (e.g. IP address).
  • Another security benefit comes from TCExam being Open Source Software, because it is widely known that security by obscurity is not a secure practice in the long run.
  • If you use TCExam in a controlled environment (e.g. a computer room) you can also add all the traditional security measures such as keyloggers, video cameras and so on.

Configuration

  • Per-installation secret. The installer generates a unique random K_RANDOM_SECURITY value for every installation.
  • Random values. Verification codes and one-time values are generated with a cryptographically secure pseudo-random number generator.
  • File and URL access. File and URL access is restricted through path/host allow-lists (K_FILE_ALLOWED_PATHS / K_FILE_ALLOWED_HOSTS, and the K_PDF_ALLOWED_* options for the PDF engine).
  • Registration groups. The registration form lists only the groups in K_USRREG_ALLOWED_GROUPS; K_USRREG_GROUP is always assigned.

Access control

  • Page levels. Every page enforces its access level; a page that does not set its own level requires the administrator level.
  • Operator scope. Operators see and change only the modules, subjects, questions, tests and results they are authorized for. Bulk actions on the question list require the K_AUTH_ADMIN_QUESTIONS level.
  • User editor. Editors below the administrator level can only edit their own account and users with a lower level.
  • OMR imports. OMR answer sheets are accepted only for authorized tests and only when every question and answer belongs to the test.
  • CSRF tokens. Every POST request with form data or files must carry a valid csrf_token.
  • Backups. Creating, restoring and downloading a backup requires the current user's password.
  • Log and backup directories. admin/log/.htaccess, public/log/.htaccess and admin/backup/.htaccess deny web access, with matching rules in the Docker Apache configuration.

Uploaded files

  • Upload checks. Media uploads reject markup and script types even when they are listed in K_ALLOWED_UPLOAD_EXTENSIONS, and every upload rejects server script types. File content is checked against the extension, file names are sanitized and existing files are never overwritten.
  • Plain SVG only. SVG files are accepted only as well-formed UTF-8 documents with static graphics. See Uploaded files for the rules and for how to export plain SVG files from common editors.
  • Imports. User, question and SSL certificate imports are read from the PHP temporary upload directory.
  • No embedded objects. Previews and [object] tags display images, audio and video with <img>, <audio> and <video>, and every other file type as a download link.
  • Passive cache/ folder. The shipped cache/.htaccess and the Docker Apache configuration serve cache/ as passive content.

Exams and content

  • Exam attempts. The exam page displays and stores answers only for the examinee's active attempt.
  • LaTeX. [tex] in free-text answers and test comments is not compiled, and pdflatex runs with restricted file access and without shell escape. See the LaTeX rendering page.
  • Output escaping. User-supplied text is HTML-escaped on the administration and public pages and in the PDF reports.

Installer

  • The web installer refuses to run on an installed instance. The Docker image denies web access to install/.

Isolating the administration area

The /admin/ path manages users, questions, tests and results. Treat it as a separate, internal service, so that TCExam's own login is not the only barrier:

  • Separate entry point. Serve /admin/ from a dedicated virtual host or hostname and deny /admin/ on the public host. Set K_PATH_URL_ADMIN in shared/config/tce_paths.php to the base URL of the admin host, and leave K_COOKIE_DOMAIN empty so that the session cookie is host-only.
  • Network restriction. Make the admin host reachable only through a VPN or an identity-aware access gateway, and drop all other traffic with a firewall. A firewall cannot filter by URL path: give the admin area its own listener (hostname with its own IP address, port or node) first.
  • Second authentication layer. Require TLS client certificates, a reverse-proxy SSO with MFA, or at least HTTP Basic authentication over HTTPS, with credentials separate from TCExam accounts.
  • Serve only what is needed. Under /admin/, serve only admin/code/*.php and admin/styles/, and deny admin/backup/, admin/log/, admin/doc/, admin/config*/ and public/log/. The admin pages also load files from shared/jscripts/, the shared/ styles and cache/.
  • Rate limiting, headers and logging. Rate-limit /admin/ requests and login POSTs, send X-Frame-Options: DENY, Referrer-Policy: no-referrer and Strict-Transport-Security, and write a dedicated access log for the admin host.
  • Split deployment (optional). On exam-delivery nodes that only serve public/, do not install admin/; run administration from an internal node against the same database.

The comparison of network options and the Apache, nginx, nftables and ufw examples are in the "Isolating the administration area" section of SECURITY.md.

Recommended hardening checklist

  • After installation, delete the install/ directory and set restrictive file permissions (see the Installation page).
  • Log in with the default admin / 1234 account, create a new level-10 administrator with a strong password and remove the default admin user immediately.
  • Serve TCExam over HTTPS and isolate the admin/ folder as described in Isolating the administration area.
  • Keep the admin/backup/ folder unreachable from the web (or move it elsewhere and set K_PATH_BACKUP in shared/config/tce_paths.php), and keep the .htaccess files of admin/backup/, admin/log/ and public/log/. On nginx, deny these three paths in the server block.
  • Keep cache/.htaccess in place and enable mod_headers with AllowOverride AuthConfig FileInfo (or All) for the TCExam folder. On nginx, add the equivalent cache/ rules listed in the Upgrade Guide.
  • After upgrading an existing installation, review the stored files and data as described in Existing data.
  • With CAS authentication, set K_CAS_SERVER_CA_CERT in shared/config/tce_cas.php so that the CAS server certificate is validated.
  • Keep PHP, the database and the Composer dependencies up to date.

For the full security policy and how to report a vulnerability, see SECURITY.md. Please report security issues privately instead of opening a public issue.