BioTime 9.5.6 Security Patch - Build 20261126.3672
==================================================

1. Applies to
-------------
BioTime 9.5.6 Build 20261015.3623 ONLY.
Check the version on the About / License page before you start: it must read
"9.5.6 (Build:20261015.3623)". Do not apply this patch to any other version.
After the patch the version reads "9.5.6 (Build:20261126.3672)".

2. What this patch fixes
------------------------
Security fixes:
  - Licensing and upgrade functions could be reached without signing in.
  - Access tokens for employee/visitor photos and for QR-code face registration
    could be forged by an unauthenticated attacker.
  - The password-reset function could be triggered for any account without
    access to the account's mailbox.
  - The fingerprint-matching function could be reached without signing in.
  - The application signing key could be predicted.
Other fixes:
  - Uploading a photo that cannot be used (e.g. a transparent PNG) now shows an
    error message instead of failing silently.
  - The software upgrade check on the License page works again.

No database change is made. Employee, attendance, device and biometric data,
and all saved passwords, are not affected.

3. Before you start
-------------------
  - Plan a maintenance window of about 15 minutes. Devices keep their records
    and upload them when the server is back.
  - Back up the BioTime installation folder (at least the "mysite" folder and
    attsite.ini), e.g. C:\ZKBioTime.
  - Check the package is genuine: in PowerShell, run
        Get-FileHash .\<file> -Algorithm SHA256
    and compare with SHA256SUMS.txt.

4. Installation
---------------
  1) Stop the BioTime services (Windows "Services"): the BioTime monitor /
     watchdog service first, then the web service (Apache), then bio-server.
     Leave the database and Redis services running.
  2) Copy the contents of the "files" folder of this package into the BioTime
     installation folder, keeping the folder structure. Overwrite when asked.
  3) Delete these files if they exist in the installation folder (an old
     source file would be loaded instead of the patched one):
        mysite\admin\sites.py
        mysite\urls.py
        mysite\tools\access_utils.py
        mysite\utils.py
        mysite\personnel\forms\employee_forms.py
  4) Start the services again: bio-server, then the web service, then the
     monitor / watchdog service.
  5) Check:
       - The About / License page shows 9.5.6 (Build:20261126.3672).
       - A "keys" folder now exists in the installation folder with
         access_token.key and django_secret.key (created on first start).
       - You can sign in, and devices show as online.

5. After the upgrade
--------------------
  - All users must sign in again once. API clients that use JWT tokens must
    request new tokens.
  - Regenerate the face-registration QR codes (employee, visitor, reservation).
    QR codes printed before the upgrade no longer work.
  - License page: each licensing operation asks for a superuser name and
    password; the check is valid for 10 minutes.
  - Password reset: the link in the e-mail now opens a confirmation page; the
    new password is e-mailed after the user confirms.
  - Several servers (e.g. web and device communication on different machines):
    set the same value for ACCESS_AES_PASSWORD in the [SYS] section of
    attsite.ini on every server, then restart the services.
  - Include the "keys" folder in your backups. If it is lost, new keys are
    created automatically; users then sign in again and QR codes must be
    regenerated. No data is lost.

6. Roll back
------------
Stop the services, restore the backed-up "mysite" folder and attsite.ini,
delete mysite\settings\components\local_keys.py if it remains, and start the
services. Rolling back re-opens the security issues fixed by this patch.

7. If you cannot install the patch immediately
-----------------------------------------------
Do not expose BioTime directly to the Internet. Allow access only from trusted
networks (firewall, VPN) until the patch is installed.
