CVE-2022-3140: warn on load when a document binds an event to a macro
authorCaolán McNamara <caolanm@redhat.com>
Wed, 7 Aug 2019 16:37:11 +0000 (17:37 +0100)
committerBastien Roucariès <rouca@debian.org>
Sat, 25 Mar 2023 10:55:37 +0000 (10:55 +0000)
commit22ebb4473a4a391ee5bb52743d0ea77a71a6d760
tree701c4a300ad4a70dbf2bb71a18b43b392b9b6d62
parentbfc5cdad8e7331fc584018f82a58c9001c8e02cf
CVE-2022-3140: warn on load when a document binds an event to a macro

a) treat shared/Scripts equivalently to document scripts

This doesn't automatically warn/block running those scripts when used in a
freshly loaded document on its own however

because DocumentMacroMode::checkMacrosOnLoading will see at...

if ( m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() )

that the document contains no macros and flip the allow macros flag to true so
that potentially new uses of macros added by the user during the edit are
allowed to run

b) so, add an additional flag to indicate existence of use of macros in a document

c) for odf import, set it when a script:event-listener tag is encountered
d) for html import when registerScriptEvents or SwFormatINetFormat::SetMacroTable is called
e) for doc import when Read_F_Macro or StoreMacroCmds is called as well for good measure
f) for xls import when registerScriptEvent or ScMacroInfo::SetMacro is called
g) for oox import when VbaProject::attachMacros is called

Reviewed-on: https://gerrit.libreoffice.org/77387
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
(cherry picked from commit 35fe064a67b54b0680b4845477c9b8751edda160)

Change-Id: Ic1203d8ec7dfc217aa217135033ae9db2888e19b
Reviewed-on: https://gerrit.libreoffice.org/83348
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
origin: https://github.com/LibreOffice/core/commit/96b7887cbfd24bb29e08667b027a86f79c246ce2
bug-debian-security: https://deb.freexian.com/extended-lts/tracker/CVE-2022-3140
bug: https://deb.freexian.com/extended-lts/tracker/CVE-2022-3140

Gbp-Pq: Name 0071-CVE-2022-3140-warn-on-load-when-a-document-binds-an-.patch
32 files changed:
comphelper/source/misc/documentinfo.cxx
dbaccess/source/core/dataaccess/ModelImpl.cxx
dbaccess/source/core/dataaccess/databasedocument.cxx
dbaccess/source/core/inc/ModelImpl.hxx
include/comphelper/documentinfo.hxx
include/oox/ole/axcontrol.hxx
include/sfx2/docmacromode.hxx
include/sfx2/objsh.hxx
include/xmloff/xmlimp.hxx
oox/source/ole/vbaproject.cxx
sc/source/filter/excel/xiescher.cxx
sc/source/filter/inc/xiescher.hxx
sc/source/ui/vba/vbasheetobject.cxx
sc/source/ui/vba/vbasheetobject.hxx
scripting/source/protocolhandler/scripthandler.cxx
sfx2/source/doc/docmacromode.cxx
sfx2/source/doc/objmisc.cxx
sfx2/source/doc/objstor.cxx
sfx2/source/doc/objxtor.cxx
sfx2/source/doc/sfxbasemodel.cxx
sfx2/source/inc/objshimp.hxx
sfx2/source/notify/eventsupplier.cxx
sw/source/filter/html/htmlform.cxx
sw/source/filter/html/htmlgrin.cxx
sw/source/filter/html/swhtml.cxx
sw/source/filter/html/swhtml.hxx
sw/source/filter/ww8/ww8par.cxx
sw/source/filter/ww8/ww8par.hxx
sw/source/filter/ww8/ww8par5.cxx
sw/source/filter/ww8/ww8toolbar.cxx
xmloff/source/core/xmlimp.cxx
xmloff/source/script/XMLEventImportHelper.cxx