![]() |
Threat model and pitfalls | ![]() |
This page summarizes what the mechanisms of this chapter protect against, as they are implemented, and lists the known weaknesses and bugs. File names are relative to
src/TeXmacs/progs/
for Scheme files and to
src/src/
for C++ files.
A document which does not lie below $TEXMACS_SECURE_PATH should not be able to run arbitrary Scheme code when it is opened, typeset or clicked, unless the user chose “accept all scripts” or confirmed a prompt. The protection relies entirely on the static checker secure? and on the honesty of the :secure declarations.
Encrypted regions and encrypted documents are stored on disk only in encrypted form, as long as they are in their encrypted state when the file is written. Passphrases are passed to gpg through pipes, never on the command line, and stored only in memory and, if the user wishes, in the wallet and the system keychain.
Trusted locations are trusted completely. Everything below $TEXMACS_PATH and $TEXMACS_HOME_PATH is trusted, including the scratch directory in which new unnamed documents are created ($TEXMACS_HOME_PATH/texts/scratch) and the temporary directory ($TEXMACS_HOME_PATH/system/tmp). Material pasted into a new document therefore runs with full rights, and so do files which other programs store below the user's TeXmacs directory.
The trust status is computed once. The environment of an editor takes its secure flag from the master of the buffer when the editor is created (
Typeset/Env/env.cpp:37
); edit_typeset_rep::typeset_prepare updates the base file name but not the flag. A document keeps the trust status of its original location after Save as (in both directions) until it is reopened.
Decrypted regions are plain text. A region in its decrypted state is saved, autosaved, exported, copied and kept in the undo history in clear. Nothing encrypts regions automatically before saving; the user has to encrypt them explicitly.
No authenticity. Regions are encrypted, not signed, and gpg-encrypt uses --trust-model always: anyone who has the public keys (which are stored in the document itself) can produce an encrypted region for the same recipients, and nothing checks that a key belongs to the person its user identifier names.
Metadata. Encrypted regions list the fingerprints of their recipients in clear, and the attachment gpg contains their user identifiers and public keys. Whole-document encryption hides everything except the fact that the file is encrypted.
Memory. Decrypted documents, the passphrase table of encrypted buffers and, while it is on, the whole wallet are held in clear in the memory of the process.
security/gpg/gpg-edit.scm
), gpg-set-default-key-fingerprint, which sets a preference (
security/gpg/gpg-widgets.scm:51
), tm-gpg-collect-public-keys-from-buffer, which writes the file of collected keys (
security/gpg/gpg-base.scm:225
), and gpg-get-default-key-fingerprint, which reveals the fingerprint of the user's default key. Untrusted documents can call all of them.
texmacs/texmacs/tm-files.scm:389
). The hook should refuse to write instead. Also, export_tree calls the hook whenever the variable encryption is present, whatever its value.
security/gpg/gpg-base.scm:429
), so deleting a public key in the key manager (
security/gpg/gpg-widgets.scm:606
) also deletes the corresponding secret key, although the confirmation dialog only mentions public keys.
security/gpg/gpg-edit.scm:362
), which is not defined (the function is gpg-ask-standalone-passphrase). All menu entries, icons and alternate-toggle for passphrase encrypted regions end in an unbound variable error.
The error path of system-security-delete-generic-password on Windows refers to an unbound variable cmd (
security/keychain/win-security.scm:61
).
The wallet dialogs read the second form value (the “remember passphrase” choice) even when that field is not shown because no system keychain is available (
security/wallet/wallet-menu.scm:98
, 142, 185).
When the wallet is on, gpg-wallet-reinitialize restores the old entries only in memory (security/gpg/gpg-wallet.scm:135-137); the new table.gpg stays empty until the next change of the wallet.
generate-password draws the characters with GnuTLS but shuffles them with the ordinary random (
security/password.scm:33
), and falls back to random entirely without GnuTLS (line 26).
The file of collected public keys is computed once, when
gpg-base.scm
is loaded (line 166), from the user who is the default user at that time.
The field new_buffer_rep::secure (
Texmacs/Data/new_buffer.hpp:31
) is initialized but never read; the checks use the flag of the typesetting environment.