Makefile.fetch | 2 - include/sfx2/objsh.hxx | 2 + librelogo/source/LibreLogo/LibreLogo.py | 51 +++++++++++++++++++++++++++++++- sfx2/source/doc/objmisc.cxx | 36 ++++++++++++++++++++++ sfx2/source/notify/eventsupplier.cxx | 18 +++++++---- 5 files changed, 101 insertions(+), 8 deletions(-)
New commits: commit ca5761d4b5af8b0df7212e2b344b37ecf9ef26e0 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Mon Aug 5 16:39:29 2019 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Aug 5 16:39:29 2019 +0200 Makefile.fetch: fix libpng download, it has MD5SUM variable Change-Id: I2938d4b92f64f991887cacb490f6b5cb3407212e diff --git a/Makefile.fetch b/Makefile.fetch index 3bfca1e61c36..e497fe02e7be 100644 --- a/Makefile.fetch +++ b/Makefile.fetch @@ -78,6 +78,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR) $(call fetch_Optional,CURL,CURL_TARBALL) \ $(call fetch_Optional,EXPAT,EXPAT_TARBALL) \ $(call fetch_Optional,GRAPHITE,GRAPHITE_TARBALL) \ + $(call fetch_Optional,LIBPNG,PNG_TARBALL) \ $(call fetch_Optional,MSPUB,MSPUB_TARBALL) \ $(call fetch_Optional,MWAW,MWAW_TARBALL) \ $(call fetch_Optional,NSS,NSS_TARBALL) \ @@ -151,7 +152,6 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR) $(call fetch_Optional,OPENLDAP,$(OPENLDAP_TARBALL)) \ $(call fetch_Optional,ORCUS,$(ORCUS_TARBALL)) \ $(call fetch_Optional,CAIRO,$(PIXMAN_TARBALL)) \ - $(call fetch_Optional,LIBPNG,$(PNG_TARBALL)) \ $(call fetch_Optional,POSTGRESQL,$(POSTGRESQL_TARBALL)) \ $(call fetch_Optional,REDLAND,$(RAPTOR_TARBALL)) \ $(call fetch_Optional,REDLAND,$(RASQAL_TARBALL)) \ commit 3ad87895c70bde10ca56e806086edfb41591454f Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Jul 26 13:25:31 2019 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Aug 5 16:23:28 2019 +0200 decode url escape codes and check each path segment Change-Id: Ie8f7cef912e8dacbc2a0bca73534a7a242a53ca1 Reviewed-on: https://gerrit.libreoffice.org/76378 Reviewed-by: Stephan Bergmann <sberg...@redhat.com> Tested-by: Jenkins (cherry picked from commit 7942929685fafb0f9c82feb8da7279e5103c87f0) Reviewed-on: https://gerrit.libreoffice.org/76453 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> (cherry picked from commit 9323b4ff84ffcd33ced656d5277982add00a9b17) diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 32b663554875..aafe8755a627 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -53,6 +53,8 @@ #include <com/sun/star/script/provider/XScriptProvider.hpp> #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp> #include <com/sun/star/ucb/SimpleFileAccess.hpp> +#include <com/sun/star/uri/UriReferenceFactory.hpp> +#include <com/sun/star/uri/XVndSunStarScriptUrlReference.hpp> #include <com/sun/star/util/XModifiable.hpp> #include <toolkit/unohlp.hxx> @@ -1524,7 +1526,32 @@ namespace // don't allow LibreLogo to be used with our mouseover/etc dom-alike events bool SfxObjectShell::UnTrustedScript(const OUString& rScriptURL) { - return rScriptURL.startsWithIgnoreAsciiCase("vnd.sun.star.script:LibreLogo"); + if (!rScriptURL.startsWith("vnd.sun.star.script:")) + return false; + + // ensure URL Escape Codes are decoded + css::uno::Reference<css::uri::XUriReference> uri( + css::uri::UriReferenceFactory::create(comphelper::getProcessComponentContext())->parse(rScriptURL)); + css::uno::Reference<css::uri::XVndSunStarScriptUrl> sfUri(uri, css::uno::UNO_QUERY); + + if (!sfUri.is()) + return false; + + OUString sScript = sfUri->getName(); + + // check if any path portion matches LibreLogo and ban it if it does + sal_Int32 nIndex = 0; + do + { + OUString aToken = sScript.getToken(0, '/', nIndex); + if (aToken.startsWithIgnoreAsciiCase("LibreLogo")) + { + return true; + } + } + while (nIndex >= 0); + + return false; } ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptContext, const OUString& _rScriptURL, commit 03b6b605af841e52938a07133e5b067fdae58886 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Jul 23 15:31:05 2019 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Aug 5 16:22:41 2019 +0200 expand LibreLogo check to global events Reviewed-on: https://gerrit.libreoffice.org/76189 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 4a66c7eda6ccde26a42c4e31725248c59940255d) Change-Id: I7f436983ba0eb4b76b02d08ee52626e54b103d5f (cherry picked from commit e5702eefdfe6d44a92fdfb3c6a3ff47fec83ee49) Reviewed-on: https://gerrit.libreoffice.org/76452 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> (cherry picked from commit 20465aeb082ea239239f598d42041c35b55598d6) diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index 3c4bed101d01..58f7c0e559db 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -394,6 +394,8 @@ public: */ bool AdjustMacroMode( const String& rScriptType, bool _bSuppressUI = false ); + static bool UnTrustedScript(const OUString& rScriptURL); + SvKeyValueIterator* GetHeaderAttributes(); void ClearHeaderAttributesForSourceViewHack(); void SetHeaderAttributesForSourceViewHack(); diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 90edbb5fdf71..32b663554875 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1521,16 +1521,12 @@ namespace } } -namespace { - // don't allow LibreLogo to be used with our mouseover/etc dom-alike events -bool UnTrustedScript(const OUString& rScriptURL) +bool SfxObjectShell::UnTrustedScript(const OUString& rScriptURL) { return rScriptURL.startsWithIgnoreAsciiCase("vnd.sun.star.script:LibreLogo"); } -} - ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptContext, const OUString& _rScriptURL, const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam, bool bRaiseError, const ::com::sun::star::uno::Any* pCaller ) { diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx index d760a30385e4..114cdc96abc1 100644 --- a/sfx2/source/notify/eventsupplier.cxx +++ b/sfx2/source/notify/eventsupplier.cxx @@ -219,18 +219,24 @@ static void Execute( uno::Any& aEventData, const document::DocumentEvent& aTrigg else if (aType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Service")) || aType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Script"))) { - if ( !aScript.isEmpty() ) + bool bAllowed = false; + util::URL aURL; + if (!aScript.isEmpty()) { - SfxViewFrame* pView = pDoc ? - SfxViewFrame::GetFirst( pDoc ) : - SfxViewFrame::Current(); - uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); - util::URL aURL; aURL.Complete = aScript; xTrans->parseStrict( aURL ); + bAllowed = !SfxObjectShell::UnTrustedScript(aURL.Complete); + } + + if (bAllowed) + { + SfxViewFrame* pView = pDoc ? + SfxViewFrame::GetFirst( pDoc ) : + SfxViewFrame::Current(); + uno::Reference < frame::XDispatchProvider > xProv; commit 35c152c9fa5987c5934d56194856e76abeb1402a Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Jun 7 14:04:07 2019 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Aug 5 16:21:39 2019 +0200 explictly exclude LibreLogo from XScript usage Change-Id: I567647f0e2f8b82e4ef2995c673abe82f4564228 Reviewed-on: https://gerrit.libreoffice.org/73659 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit cb0024e3668979dfdef44db5aa15ddfaf035e695) Reviewed-on: https://gerrit.libreoffice.org/74282 Reviewed-by: Michael Stahl <michael.st...@cib.de> Tested-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit 17046049d5028ab6ef3e0d3bddf18d49e6213126) diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 1bde2aef2167..90edbb5fdf71 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1521,6 +1521,16 @@ namespace } } +namespace { + +// don't allow LibreLogo to be used with our mouseover/etc dom-alike events +bool UnTrustedScript(const OUString& rScriptURL) +{ + return rScriptURL.startsWithIgnoreAsciiCase("vnd.sun.star.script:LibreLogo"); +} + +} + ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptContext, const OUString& _rScriptURL, const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam, bool bRaiseError, const ::com::sun::star::uno::Any* pCaller ) { @@ -1533,6 +1543,9 @@ ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptCon if ( bIsDocumentScript && !lcl_isScriptAccessAllowed_nothrow( _rxScriptContext ) ) return ERRCODE_IO_ACCESSDENIED; + if ( UnTrustedScript(_rScriptURL) ) + return ERRCODE_IO_ACCESSDENIED; + bool bCaughtException = false; Any aException; try commit 46891e29e3fec3be99525a8f3885c61a1569f32a Author: László Németh <nem...@numbertext.org> AuthorDate: Thu Jun 6 14:25:32 2019 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Aug 5 16:20:11 2019 +0200 sanitize LibreLogo calls Change-Id: Ie4d9858e5b4b3e55ab08416fb9338d2df34ee5e1 Reviewed-on: https://gerrit.libreoffice.org/73627 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 1b63fa32bbd4a5b89d2ee3a53b28de4250c8dad3) Reviewed-on: https://gerrit.libreoffice.org/74281 Reviewed-by: Michael Stahl <michael.st...@cib.de> Tested-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit 3b490c0f22f06911c17589ff0bf17b4dfbf41726) diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py index 913ae6b0b2de..af1bb1b1cfe5 100644 --- a/librelogo/source/LibreLogo/LibreLogo.py +++ b/librelogo/source/LibreLogo/LibreLogo.py @@ -67,6 +67,7 @@ __LineStyle_DOTTED__ = 2 class __Doc__: def __init__(self, doc): self.doc = doc + self.secure = False try: self.drawpage = doc.DrawPage # Writer except: @@ -375,10 +376,58 @@ class LogoProgram(threading.Thread): self.code = code threading.Thread.__init__(self) + def secure(self): + # 0 = secure + if _.secure: + return 0 + + # 1 = forms, fields or embedded objects are forbidden + if _.doc.DrawPage.Forms.getCount() > 0 or _.doc.getTextFields().createEnumeration().hasMoreElements() or _.doc.getEmbeddedObjects().getCount() > 0: + return 1 + + # 2 = hyperlinks with script events + nodes = _.doc.Text.createEnumeration() + while nodes.hasMoreElements(): + node = nodes.nextElement() + if node.supportsService("com.sun.star.text.Paragraph"): + portions = node.createEnumeration() + while portions.hasMoreElements(): + portion = portions.nextElement() + if portion.PropertySetInfo.hasPropertyByName("HyperLinkEvents"): + events = portion.getPropertyValue("HyperLinkEvents") + for event in events.getElementNames(): + attributes = events.getByName(event) + for attribute in attributes: + if attribute.Name == "EventType" and attribute.Value == "Script": + return 2 + + # 2 = images with script events + images = _.doc.DrawPage.createEnumeration() + while images.hasMoreElements(): + image = images.nextElement() + try: + events = image.Events + for event in events.getElementNames(): + attributes = events.getByName(event) + for attribute in attributes: + if attribute.Name == "EventType" and attribute.Value == "Script": + return 2 + except: + pass + + _.secure = True + return 0 + def run(self): global __thread__ try: - exec(self.code) + # check document security + secid = self.secure() + if secid > 0: + parent = _.doc.CurrentController.Frame.ContainerWindow + MessageBox(parent, "Document objects with%s script events" % [" possible", ""][secid-1], "LibreLogo program can't start", "errorbox") + else: + exec(self.code) if _.origcursor: __dispatcher__(".uno:Escape") try: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits