Penetration Test Report (X41 D-Sec): X41 OSTIF Go TUF Audit 2023 Public

CodeReviewoftheGoTUFImplementation
forOSTIF
FinalReportandManagementSummary
2023-05-31
PUBLIC
X41 D-SEC GmbH
Krefelderstr. 123
D-52070 Aachen
Amtsgericht Aachen: HRB19989
https://x41-dsec.de/
info@x41-dsec.de
OrganizedbytheOpenSourceTechnologyImprovementFund
CodeReviewoftheGoTUFImplementation OSTIF
Revision Date Change Author(s)
1 2023-03-17 FinalReportandManagement L.Gommans,M.Vervier,N.Abel
Summary
2 2023-05-31 PublicRelease L.Gommans
X41D-SecGmbH PUBLIC Page1of28
CodeReviewoftheGoTUFImplementation OSTIF
Contents
1 ExecutiveSummary 4
2 Introduction 6
2.1 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 FindingsOverview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4 Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.5 RecommendedFurtherTests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3 RatingMethodologyforSecurityVulnerabilities 10
3.1 CommonWeaknessEnumeration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4 Results 12
4.1 Findings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2 FuzzTesting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.3 InformationalNotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5 AboutX41D-SecGmbH 27
X41D-SecGmbH PUBLIC Page2of28
CodeReviewoftheGoTUFImplementation OSTIF
Dashboard
Target
Customer OSTIF
Name go-tuf
Type CommandLineApplication
Version Commitfab805a8e00b5520
Engagement
Type CodeReview
Consultants 3:LucGommans,MarkusVervierandNiklasAbel
EngagementEffort 12person-days,2023-02-27to2023-03-10
Totalissuesfound 2
Critical - 0
High - 0
Medium - 1 CWE-59(1) CWE-1025(1)
Low - 1
None - 4
0 1 2 3 4
Figure1:IssueOverview(l:Severity,r:CWEDistribution)
X41D-SecGmbH PUBLIC Page3of28
CodeReviewoftheGoTUFImplementation OSTIF
1 Executive Summary
InMarch2023,X41D-SecGmbHperformedasourcecodeauditagainstgo-tuftoidentifyvul-
nerabilities and weaknesses in the application. go-tuf is a Go implementation of The Update
Framework which allows developers to securely manage updates of software and to minimize
theimpactonusersintheeventthatupdatedistributionserversormirrorsarecompromised.
TwovulnerabilitywerediscoveredduringthetestbyX41,ratedasamediumandalowseverity.
Afurtherfourissueswithoutadirectsecurityimpactwereidentified.Ananalysisoffuzztesting
fortheprojectwasadditionallyperformed.
Thetestwasperformedbythreeexperiencedsecurityexpertsbetween2023-02-27and2023-
03-10. Inasourcecodeaudit,allinformationaboutthesystemismadeavailable,althoughpos-
sibleenvironmentalandsetupspecificsmightstillleadtoweaknessesthatarenotvisibleinthe
sourcecode.
One discovered issue allows an attacker to provide erroneous updates under certain circum-
stances. Theupdatefilesarenotmaliciousthemselves,butduetonotbeingtheexpectedfiles,
thislikelystillleadstothesystemnotfunctioninganymoreafteranupdateor,againdepending
oncircumstances,couldleadtoacompromiseofthetargetsystem.
Specifically, files can be taken from one repository and provided as updates in another. The
main prerequisite is using the same signing keys, which could happen if both TUF repositories
aremanagedbythesameindividual.Theattackcanbetechnicallymitigatedbytyingversionsto
eachother(aconsecutiveupdatewouldnotbevalidbecauseitwouldlinktoadifferentpreceding
file) or by making root metadata specific to a project such as by including a random value that
would not be present in the other project. Stating in the documentation that unique keys are
requiredwouldbeanorganizationalsolution,butmightbemissedbyamaintainer.
Another issue might allow an attacker to overwrite files on the local system of a committer by
placingsymboliclinksintoacompromisedrepository. Thismighthappenduetoacompromise
intransitoffilesonwhichgo-tufthenoperates. Whetherthefilesarealreadysignedbyother
functionariesdoesnotmatterbecausesuchsignaturesarecurrentlynotvalidated.
X41D-SecGmbH PUBLIC Page4of28
CodeReviewoftheGoTUFImplementation OSTIF
Amonginformationalnotes,itwasnoticedthatkeys/directorypermissionsaresettobeworld-
readable. This does not allow a local attacker to read the key files themselves, but it is best
practicetoassignonlytheminimumpermissionsnecessary.
Overall,theprojectshowsahighmaturityintermsofsecurity. X41recommendstoresolvethe
identifiedissuesandcontinuetoapplybestpracticesandhardeningtotheapplication.
X41D-SecGmbH PUBLIC Page5of28
CodeReviewoftheGoTUFImplementation OSTIF
2 Introduction
X41reviewedtheGoimplementationofTheUpdateFramework.Thesystemallowsdevelopers
tosecurelymanageupdatesofsoftwareandtominimizetheimpactonusersintheeventthat
updatedistributionserversormirrorsarecompromised.
Attackers could try to attack the various components of the system which each have to work
correctly, including the parsing of downloaded data, the download mechanism itself, and the
signaturesofthemetadataandtargetfiles.
2.1 Methodology
Thereviewconsistedofasourcecodeaudit.
AmanualapproachforpenetrationtestingandforcodereviewisusedbyX41. Thisprocessis
supportedbytoolssuchasstaticcodeanalyzersandindustrystandardwebapplicationsecurity
tools1.
X41adherestoestablishedstandardsforsourcecodereviewingandpenetrationtesting. These
areinparticulartheCERTSecureCoding2 standardsandtheStudy-APenetrationTestingModel3
oftheGermanFederalOfficeforInformationSecurity.
1https://portswigger.net/burp
2https://wiki.sei.cmu.edu/confluence/display/seccode/SEI+CERT+Coding+Standards
3https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Publications/Studies/Penetration/penetrati
on_pdf.pdf?__blob=publicationFile&v=1
X41D-SecGmbH PUBLIC Page6of28
CodeReviewoftheGoTUFImplementation OSTIF
Ini�al Design Threat Code
Workshop Modelling Review
Fixing and GAP / Performance
Documenta�on
Mi�ga�on Analysis
Figure2.1:CodeReviewMethodology
2.2 Findings Overview
DESCRIPTION SEVERITY ID REF
KeyReuseAllowsCut-And-PasteAttack LOW GOTUF-CR-23-01 4.1.1
SymbolicLinkAttacksPossibleDuringCommitOperation MEDIUM GOTUF-CR-23-02 4.1.2
KeyFolderPermissions NONE GOTUF-CR-23-100 4.3.1
HintAboutInsecurePasswords NONE GOTUF-CR-23-101 4.3.2
UnhandledErrors NONE GOTUF-CR-23-102 4.3.3
SuboptimalScryptParameters NONE GOTUF-CR-23-103 4.3.4
Table2.1:Security-RelevantFindings
2.3 Scope
Thescopeconsistsofthesourcecodeinthefollowingrepository.Astargetversion,theuntagged
commitID4 fab805a8e00b5520c09855385b32761f41b67a6f isused, whichwasthelatestcom-
mitatthestartoftheaudit.
https://github.com/theupdateframework/go-tuf
4Identifier
X41D-SecGmbH PUBLIC Page7of28
CodeReviewoftheGoTUFImplementation OSTIF
Arepositoryserverimplementationisalsocontained,butthefocusoftheauditshouldbeonthe
clientcode.Thespecificationtowhichthecodewillbecomparedcanbefoundhere:
https://theupdateframework.github.io/specification/latest/
ThespecificationitselfisnotpartofthescopeasitwasalreadyauditedwiththereferencePython
implementation5.Dependenciesofgo-tufarealsonotpartofthescope.
2.4 Coverage
Asecurityassessmentattemptstofindthemostimportantorsometimesasmanyoftheexisting
problemsaspossible,thoughitispracticallyneverpossibletoruleoutthepossibilityofadditional
weaknessesbeingfoundinthefuture.
The time allocated to X41 for this assessment yielded a decent coverage of the given scope.
Directdependenciescouldnotbeinvestigatedinthetimegiven.
The nature of the project (no interface to present user data using, e.g., HTML6) and the use of
Go excludes various bug classes such as most memory corruption vulnerabilities. The use of a
key-valuedatabasewhichdoesnotuseSQL7excludesthebugclassofquerylanguageinjections.
Thekeygenerationmechanismwasreviewedforweaknesses.Sensiblecryptographicprimitives
areusedthroughoutthecode, rulingoutvariouscryptographicattacks. Clientcommandssuch
asinitarerobust,removingoldstate(i.e.: keymaterial)ifitwasaccidentallyissuedtwicewith
differentre