Security improvements
in
Iff
Live
PREINING Norbertアクセリア株式会社、東京都
Tr
Live Team北陸先端科学技術大学院大学、能美市
AbstractWereport onsecurity improvements inthe
TEX
Live distribution introducedfor the release 2016. We present
possible
attack vectors on older releases, andexplainhow therecent changesrender these attackvectorsimpossible.
1
Introduction
Since the switch to the current distribution method and the introduction of network installs and
updates,
manythings
havechanged
intheTEX
(Live)
world. Butonething
hasnt
kept
up with thenewdistribution methods:security.
Therewas
hardly
any verificationgoing
onwhether thepackage
downloaded fromtheCTANmirrorshavent been
tampered
with. Andalthough
we areshipping
checksumand file size
information,
thesewereonly
usedon rareinstances(when
restarting
afailedinstallation).
We will recall the
general layout
of thei\mathrm{E}\mathfrak{c}
Livedistribution,
aswell asthesecurity
state up till release 2015 and
possible
attack vectors ontoTEX
Live installations in Section 1.1. Thefollowing
Section 2explains
the newsecurity
infrastructure and howintegrity
andauthenticity
canbeguaranteed by
it. Thefollowing
Section 3 is dedicatedto
implementational
and socialproblems
we faced in the process ofintroducing
thesechanges,
aswell asgeneral
userexperience.
1.1
Overview
onthe
TEX
Live distribution model
While we cannot
give
a detailedexplanation
of theinternals,
as well as refrain fromgiving
apractical
introduction tousing
the\mathrm{J}\mathrm{B}K
LiveManager tlmgr,
wewant togive
anoverviewhowpackages
areinstalledby
tlmgr
(and
similarly
by
the installscript),
asthis is a necessary
prerequisite
inunderstanding
thesecurity
implications.
We assumethat the reader has
experience
inusing
[\mathrm{p}\mathfrak{c}
Live as well as the \mathrm{T} LiveManager
tlmgr.
Every Iffl
Liveinstance,
that isanyactual installationon auserscomputer,
aswellasthe
repositories
used to distributeTEX Live,
carries all of the relevant information bundledinonefile,
theso call?$\Psi$
Live Database[4],
normally
named texlive.tlpdb.
Thisfile contains
general
information about theinstance,
likesetting
of the usedrepos‐itories,
or distributionformat,
as well as all containedpackages
with list of files etc.Thus,
this fileplays
acentralrole ineveryoperation tlmgr
iscarrying
out.In
particular,
whathappens
whena useraskstlmgr
toupdate
the installationisthe1.
tlmgr
loads the local database and determines the set of installedpackages,
2. loads theremotedatabase(the
onefrom the usedrepository)
3. compares the revision numbers and determines
packages
that need to be up‐date/added/removed,
4. for each
package
tobeupdated
(or
installed)
between 1 and 3socalled containers(currently
tar.xzarhcives)
aredownloaded,
5. each container is
unpacked
into the destination tree and the local database up‐ dated.1.2
IEX
Live
security
status up torelease
2015Till
2015,
thetexlive.tlpdbattheserversdidcontaincertainconsistency information,
in
particular
the sizeof the containersaswellastheir checksum(md5),
seethefollowing
excerpt
from atexlive.tlpdb:
name 12 manycontainersize 2100
\mathrm{c}ontainermd5 . . . . .
doccontainersize 375404
do\mathrm{c}containermd5 . . . .
This information could be used to at least
guarantee
that the correct containers have beendownloaded,
but it turned out that our programs, inparticular
tlmgr
andthe installation routines did not use these information
during
normal runs, butonly
during interrupted
installations. 1.3Possible
attack
vectorsImproving
security
brings
firstacomplication
of thenecessarysoftware,
increasedwork‐load of the
maintainers,
changed
behaviorforusers, and thus it is wise to discuss first whether a bettersecurity
model is necessary. This can be doneby
scrutinizing
theinfrastructure for
possible
attackvectors,andlooking
attheconsequencesfor theusers.Weconsider theworstcasescenario for theuser,
namely
thatacrypto‐virus
infectedthecomputer and all data is lost.
1.3.1 Attackvector 1
In the
simplest
case an attackcanbe carried outby
thefollowing
steps: 1.compromise
oneCTAN mirror2.
exchange
thepdftex binary
with oneshipping
acrypto‐virus
3. wait forusersto
update
Itmustbenoted that worldwide thereare alot of differentCTAN
mirrors,
practically
all of themoutofour
personal
control. Wecannoteven check thesecurity
levelontheseThis attackvector could be blocked
by
actually checking
the checksum asprovided
by
the texlive.tlpdb.
And whilechanges implementing
this feature have been in tlcritical(a
testing repository
forchanges
totheinfra‐structure of\mathrm{I}|\mathrm{E}\mathrm{X}
Live),
thesechanges
werenevershipped
out tousers.1.3.2 Attackvector 2
Another
possible
attachvector, a bit more involved than theprevious,
consists of theabove
steps
plus
one more:1.
compromise
one CTANmirror2.
exchange
thepdftex binary
with oneshipping
acrypto‐virus
3.
adjust
the containerin awaythat the checksum doesnotchange
4. waitforusersto
update
Here the attacker would
byte‐pad
the container in a waythat the checksum isnotchanged.
Notethat while thisispossible
for the checksumalgorithm
wehave beenusing
till now
(MD5),
therequirement
that theresulting
file still works as a tar.xz archiverestricts this attack.
While less
likely
tohappen,
this attackvectorcouldnt be blockeduptill release 2016.1.4
Attack
vector 3Finally,
let us consider themostprobable
attackvector:1.
compromise
one CTANmirror(or
set oneupyourself!)
2.
exchange
thepdftex binary
with oneshipping
acrypto‐virus
3.
adjust
the checksuminthe texlive.tlpdb
4. waitforusersto
update
Indeed,
an intruder that canchange
the containers itselfis ofcourse also able tochange
the data in the texlive.tlpdb,
thusrendering
allprotective
measures futile.Again,
uptill release 2016 therewas noway to handle this attackvector.This short list of rather
simple
attack scenariosgives
a clear indication that there isample
way toimprove.
2
Security
infrastructure
From the
previous
discussion onpossible
attack vectors one can extract tworequire‐
ments of the distribution mechanism necessary to
guarantee security:
Integrity
andauthenticity
Integrity
of thepackages
downloaded: Here anykind oftampering
should becaught,
not
only by
intruders but alsoby
errorsinthe downloadprocessor diskerrors ontheserver.
Checksums are
normally
used forintegrity,
and because thecurrently
used MD5isnot
strong
enough,
we have switchedto SHA512.Authenticity
guarantees
thatthepackage
downloaded isactually
theonethatwetheTo
guarantee
authenticity
weintroducedcryptographic signatures.
2.1
Overview of the
verification architecture
The
general
flow ofpackage
download and verification isasfollows:Checking
authenticity
of the downloaded texlive.tlpdb
is doneby
first down‐loading
itsrespective
checksum texlive.tlpdb. sha512, as well as thecryptographic
signature
of the checksumfile,
namedtexlive.tlpdb.
sha512.asc. TheGNUPrivacy
Guard
(gnupg)
is used toverify
that the downloadedsignature
and the checksumfile agree. We refer the reader to introductions toasymmetric
cryptography
concerning
details of this process.texlive.
tlpdb
\rightarrow texlive.tlpdb.
sha512name 00texlive.
config
<128\mathrm{h}・ \mathrm{x}digits
>\mathrm{t}・ \mathrm{x}・ \mathrm{i}・\mathrm{e}.\mathrm{t}・・
\mathrm{d}\mathrm{b}\downarrow
texlive.
tlpdb.
sha512.ascname 12many
containerchecksum ...
----‐BEGIN PGP
SIGNATURE
iQEVAwUBVyAV9kzhh3.
..name
2\mathrm{u}\mathrm{p}
\mathrm{r}2\mathrm{m}\mathrm{B}9\mathrm{x}\mathrm{E}\mathrm{n}\mathrm{R}402 SRBDNI\ldotscontainerchecksum ... .. .
----‐END PGP SIGNATURE
2.2
The
signing key
Asymmetric
cryptography
involves akey‐pair
with aprivate
and apubhc
key.
Theprivate
key
is usedto createsignatures,
and thepublic
key
isused toverify
signatures
(encryption
is anotheruse case, butnot relevantto thisarticle).
Theprivate
key
usedis
(slighly
editedoutput to fit thepage):
pub 2048\mathrm{R}/06\mathrm{B}\mathrm{A}\mathrm{B}6\mathrm{B}\mathrm{C} 2016−03−19Key fingerprint=\mathrm{C}78\mathrm{B} 82\mathrm{D}8 C795 12\mathrm{F}7 9\mathrm{C}\mathrm{C}0 \mathrm{D}7\mathrm{C}8 0\mathrm{D}5\mathrm{E} 5\mathrm{D}91 06\mathrm{B}\mathrm{A} \mathrm{B}6\mathrm{B}\mathrm{C} uid TeX Live Distribution <\mathrm{t}\mathrm{e}\mathrm{x}‐live@tug.org>
sig 3 06\mathrm{B}\mathrm{A}\mathrm{B}6\mathrm{B}\mathrm{C} 2016-03-19 TeX Live Distribution <\mathrm{t}\mathrm{e}\mathrm{x}‐live@tug.org>
sig 3 06\mathrm{B}\mathrm{A}\mathrm{B}6\mathrm{B}\mathrm{C} 2016-03-19 TeX Live Distribution <\mathrm{t}\mathrm{e}\mathrm{x}‐live@tug.org>
sig 860\mathrm{C}\mathrm{D}\mathrm{C}13 2016-03-20 Norbert Preining <norbert@preining.info>
It
carries,
besidestheself‐signatures,
thesignatures
of KarlBerry
andmyself,
and thus allowseasy trustverificationsincebothourkeys
areavailable from the usualkey
servers, aswell asin mycasethe Debiankeyring.
As atechnical
detail,
we arenotusing
the actualprivate key
togenerate
signatures,
buta socalledsub‐key,
andkeep
the mainkey
completely
off‐line. Thisguarantees
thatin caseofa breachof thetug.orgserver and
compromise
of the usedsigning key,
themain
key
is notcompromised
aindcanbe usedtorevoke thesubkey
andgenerate
a newone.
2.3
Discussion
2.3.1
Integrity
Due to the
stringent
verification of checksums of all downloadedfiles,
theintegrity
ofany
packages
isguaranteed.
2.3.2
Authenticity
ofthe containersAuthenticity
of the downloaded$\tau$ \mathrm{f}X
Live Database texlive.tlpdb
isgiven by
thecryptographic signature.
Authenticity
of the downloaded containers isguaranteed
by
the fact that the checksum information for each containers is taken from the(authen‐
ticated)
database,
and the checksumalgorithm
(SHA512)
cannot(at
thecurrenttime)
betampered
with.3
Practical
problems
and
userexperience
As
expected,
wedid facealong
list ofproblems
andsurprises
during
theimplementation,
testing,
and transition course. In this lastpart
we discuss a few ofthem,
and howweworked around
it,
and alsoreport
onthe userexperience.
3.1
(Non‐)Distribution
of GnuPG
The whole
setup
isbased on the fact that the GNUPrivacy
Guard GnuPG[2]
is avail‐able. Without
it,
authenticity
cannotbeguaranteed,
and asconsequencealsointegrity.
Practically
all Unix‐like distributionsship GnuPG,
but there are twonotable and im‐portant
exceptions:
Windows and OSX. The default solution—as we do it for otherprograms
commonly
availableon mostplatforms
but Windows andMac,
e.g., wget‐would be to
ship
binaries of GnuPG withr\mathrm{E}\mathfrak{c}
Live.Unfortunately,
duetoalong history
ofignorant
legislative bodies, import
andexportof
crytographic
software is(might
stillbe)
heavily
restricted insomecountries,
governed
by
theWaasenaarArrangement
[1]. (For
those who remember how the firstcopyof PGP reachedEurope, they
will understandeasily!)
Andalthough
the situation haschanged
slightly
and export seems to be less restrictednowadays,
import
into somecountries,
notably
France andIndia,
seemstobe ano‐go.As TUGwedo not want to
get
involved intolegal
problems
whensending
DVDs into3.2
Alternative distribution of GnuPG
To
mitigate
theproblems
described in theprevious section,
Ipersonally
did set up arepository containing
GnuPG binaries for Windows andMac,
which allows users tosimply
add GnuPG after the initial installation. To obtain GnuPG for either of thementioned
platforms, simply
issuethefollowing
commandtlmgr
−repohttp:
//\mathrm{w}\mathrm{w}\mathrm{w}.preining.\displaystyle \inf 0/\mathrm{t}\mathrm{l}\mathrm{g}\mathrm{p}\mathrm{g}/
installtlgpg
On the
Mac,
the\mathrm{E}\mathfrak{c}
LiveUtility
(TLU)
already
offers to install GnuPG from this location on first run, and the$\Psi$ \mathrm{X}
Live infrastructure itself isprepared
to use theGnuPG installed via thisway.
3.3
Computing
checksums
Another
problem
wefacedishowtocompute checksums,
inparticular
SHA512. There is an excellentandquick
Perl moduleDigest:
:SHAwhichweinitially used,
but it turnedoutthe the default Perl distributioneven on newMacs
is,
well, old,
veryold,
and doesnot
ship
this module.We tried a view different
options,
like pure Perlimplementations,
or Luaimple‐
mentations,
but all of them werefar to slow for the amount of checksums we have tocomputer.
Asasolutionwe
implemented
amulti‐trialsystem:
Firstthe existenceofDigest:
:SHA is checked. If it is notavailable,
thefollowing
command line programs are checked inorder:
openssl,
\mathrm{s}\mathrm{h}\mathrm{a}512\mathrm{s}\mathrm{u}\mathrm{m}, and shasum. One or the other should be available on allplatforms.
3.4
Users
complains
and
experience
As laid out in the
introduction,
one of the aims was that the userexperience
shouldchange
aslittleaspossible.
During
theinitialtesting phase
wegot quite
somecomplains
that our initial
implementation
and wayofwarning
users was tointrusive,
toorough.
We have reworked the userexperience
ina waythat, although
things
are checked andverified as far as
possible, only
in worst‐case scenarios the user iswarned,
the rest of thechanges
areminimal.In
particular,
for thetlmgr
calls we nowhave thefollowing layout:
tlmgr
update
-‐list
-‐repo <CTAN>/\mathrm{t}\mathrm{l}\mathrm{n}\mathrm{e}\mathrm{t}/
tlmgr:
package repository
<CTAN>/\mathrm{t}\mathrm{l}\mathrm{n}\mathrm{e}\mathrm{t}/ (verified) Theonly
newpart
is the (verified)part,
which alsomight
look like(not verified: <reason>
wherethereasons areeithera
missing GnuPG,
or amissing signature
ontheserverside.Only
in case that asignature
was checked and couldnt beverified,
the user will3.5
Key management
Immediately
after releasewereceivedrequestforsupporting
differentsignature
keys
foralternative
repositories.
I thus have addedkey
management functions, tlmgr key,
that allows forlisting,
adding,
andremoving
of additionalkeys
tothe trusted list ofsigning
keys.
This feature is
already
inuseby
atleast theKOMA‐Script
project
[3].
4
Conclusion
With the release 2016 of
TEX
Live we are now up to the same standard ofmajor
Linux distributions which ensure
authenticity
viacryptographic
signatures.
Although
inthe
long
years of$\pi$ \mathrm{x}
Livebeing
outthere,
notone case of abuse has beenreported,
we believe thatin the current environment withhigh
risk virusesbeing
distributed inever
evolving
schemes,
tosupport
verification ofauthenticity
andintegrity
is agreat
step forward. A step that most users will not even realize it has been
made,
but stillimportant.
References
[1]
The WassenaarArrangement
onExport
Controls for Conventional Arms andDual‐Use Goods and