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
.htaccessaccess 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_SECURITYvalue 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 theK_PDF_ALLOWED_*options for the PDF engine). - Registration groups. The registration form lists only the groups in
K_USRREG_ALLOWED_GROUPS;K_USRREG_GROUPis 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_QUESTIONSlevel. - 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
POSTrequest with form data or files must carry a validcsrf_token. - Backups. Creating, restoring and downloading a backup requires the current user's password.
- Log and backup directories.
admin/log/.htaccess,public/log/.htaccessandadmin/backup/.htaccessdeny 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 shippedcache/.htaccessand the Docker Apache configuration servecache/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. SetK_PATH_URL_ADMINinshared/config/tce_paths.phpto the base URL of the admin host, and leaveK_COOKIE_DOMAINempty 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 onlyadmin/code/*.phpandadmin/styles/, and denyadmin/backup/,admin/log/,admin/doc/,admin/config*/andpublic/log/. The admin pages also load files fromshared/jscripts/, theshared/styles andcache/. - Rate limiting, headers and logging. Rate-limit
/admin/requests and loginPOSTs, sendX-Frame-Options: DENY,Referrer-Policy: no-referrerandStrict-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 installadmin/; 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/1234account, create a new level-10 administrator with a strong password and remove the defaultadminuser 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 setK_PATH_BACKUPinshared/config/tce_paths.php), and keep the.htaccessfiles ofadmin/backup/,admin/log/andpublic/log/. On nginx, deny these three paths in the server block. - Keep
cache/.htaccessin place and enablemod_headerswithAllowOverride AuthConfig FileInfo(orAll) for the TCExam folder. On nginx, add the equivalentcache/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_CERTinshared/config/tce_cas.phpso 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.