My texmf.cnf
file contains these lines:
% Allow TeX \openin, \openout, or \input on filenames starting with `.' % (e.g., .rhosts) or outside the current tree (e.g., /etc/passwd)? % a (any) : any file can be opened. % r (restricted) : disallow opening "dotfiles". % p (paranoid) : as `r' and disallow going to parent directories, and % restrict absolute paths to be under $TEXMFOUTPUT. openout_any = p openin_any = a
But if I compile the following code via lualatex
, the file /home/login/unsafe.txt
is created!
\documentclass{article}
\usepackage{luatextra}
\begin{luacode*}
function securityproblem(a)
local file = assert(io.open(os.getenv("HOME") .. "/unsafe.txt", "w"))
file:write("foobar\n")
file:write(a)
file:close()
end
\end{luacode*}
\begin{document}
\directlua{securityproblem("\today")}
\end{document}
Is luatex as secure as pdftex?
Edit:
With the --safer
option, luatex
can't write files (via io.open
) but fontspec
(for example) is unusable.
Is there a safe way to use LuaTEX with fontspec
(and other useful features of LuaTeX) ?
lualatex --safer --no-shell-escape
? The manual hints that otherwise functions such asio.open
can be used as in normal lua.