GNU TeXmacsUser manualReferenceAboutEnglish
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.

1.What is protected

Untrusted documents

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.

Confidentiality at rest

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.

2.What is not protected

3.Known weaknesses and bugs

The script checker can be bypassed.
secure-expr? (kernel/texmacs/tm-secure.scm:76-94) checks only the head symbol of each call. Calls whose head is a computed value or a variable bound by lambda or with are accepted as long as the sub-expressions are (lines 81 and 87), and symbols are accepted as expressions whatever they denote (line 88). Since any global value, including a procedure which is not declared secure, can be referred to by its name, this lets an untrusted expression reach functions that are not declared secure. set! is also treated as a secure form (line 103), so an untrusted expression can assign to global variables that are visible from the module in which it is evaluated. The checker should only accept calls whose head is a symbol with the :secure property, refuse set! and free variables that are not known constants, or be replaced by evaluation in a restricted environment.
Secure functions with side effects.
Several functions of the encryption code are declared :secure although they open dialogs or change persistent state: the dialogs which ask for passphrases or recipients (
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.

Encrypted documents may be written in clear.
When tree-export-encrypted (security/gpg/gpg-edit.scm:506-524) has no passphrase for the target file, or when gpg fails, it shows an error but returns the unencrypted document, which export_tree (Texmacs/Data/new_buffer.cpp:535-545) then writes. Passphrases are registered only for the file name of the buffer and its ~ autosave file, so this happens for instance when an encrypted document is exported in TeXmacs format to another file name, and for the # autosave file written in rescue mode (
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.

Deleting a public key deletes the secret key.
gpg-delete-public-key builds its command with gpg-executable-delete-secret-and-public-key (
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.

Passphrase encrypted regions cannot be decrypted.
tm-gpg-dialogue-passphrase-decrypt calls gpg-ask-ask-standalone-passphrase (
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.

Importing keys from a document.
In gpg-widget-import-public-keys-from-buffer (security/gpg/gpg-edit.scm:400-404) the for loop has an empty body and the import call which follows it refers to the loop variable outside the loop, so the Ok button fails.
Smaller problems.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".