summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-11-14 10:39:27 +0100
committerStephan Bergmann <sbergman@redhat.com>2013-11-14 11:13:25 +0100
commitf0a9ca24fd4bf79cac908bf0d6fdb8905dc504db (patch)
tree5f16cbc9fd307ec3d9f290ea5b93f8ceb500c726 /editeng
parent96aca98168cba4b9055f2e2a16bb1a8f6f6e57ce (diff)
rhbz#887420 Implement "block untrusted referer links" feature
For now, this checks for a trusted referer (if the BlockUntrustedRefererLinks configuration prop is set) in utl::MediaDescriptor::impl_openStreamWithURL and SvxBrushItem::GetGraphicObject. Checking in additional places will probably be necessary to block /all/ unwanted communication. Also, some places marked /*TODO?*/ currently pass in an empty referer (which is always considered trusted) and will probably need to be adapted. Ideally, Referer URIs would never be empty (and consistently use something like <private:user> for cases where access is explicitly initiated by the user and should never be blocked), but that's a very daunting task, so start small by identifying the places that potentially need blocking and adding appropriate Referer URIs there. Also, Referer information should always be computed as freshly as possible from the context in which an access attempt is made, but, again, always carrying the information from the context all the way to the relevant functions is a very daunting task, so for now store the information upon object instantiation in some cases (SvxBrushItem, SdrGrafObj, ...). The Referer URI (css.document.MediaDescriptor property; SID_REFERER) was already used to track macro execution, and there is one place in SfxApplication::OpenDocExec_Impl where opening of hyperlinks (explicitly clicked by the user) is done that needs the current document's URI as Referer to check execution of macro URIs but needs an empty (or <private:user>, see above) Referer to not block non-macro URIs. Special code has been added there to handle that. Change-Id: Iafbdc07a9fe925d9ee580d4f5778448f18f2ebd9
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/items/frmitems.cxx12
-rw-r--r--editeng/source/items/numitem.cxx2
2 files changed, 11 insertions, 3 deletions
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 18c6caea9999..4cb76d7e5569 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -43,6 +43,7 @@
#include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
#include <com/sun/star/drawing/ShadingPattern.hpp>
+#include <unotools/securityoptions.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <limits.h>
#include <comphelper/processfactory.hxx>
@@ -3409,7 +3410,7 @@ SvxBrushItem::SvxBrushItem( const GraphicObject& rGraphicObj,
// -----------------------------------------------------------------------
SvxBrushItem::SvxBrushItem(
- const OUString& rLink, const OUString& rFilter,
+ const OUString& rLink, const OUString& rReferer, const OUString& rFilter,
SvxGraphicPosition ePos, sal_uInt16 _nWhich ) :
SfxPoolItem( _nWhich ),
@@ -3418,6 +3419,7 @@ SvxBrushItem::SvxBrushItem(
nShadingValue ( ShadingPattern::CLEAR ),
pImpl ( new SvxBrushItem_Impl( NULL ) ),
maStrLink ( rLink ),
+ maReferer ( rReferer ),
maStrFilter ( rFilter ),
eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
bLoadAgain ( sal_True )
@@ -3820,11 +3822,13 @@ SvxBrushItem& SvxBrushItem::operator=( const SvxBrushItem& rItem )
DELETEZ( pImpl->pGraphicObject );
maStrLink = "";
+ maReferer = "";
maStrFilter = "";
if ( GPOS_NONE != eGraphicPos )
{
maStrLink = rItem.maStrLink;
+ maReferer = rItem.maReferer;
maStrFilter = rItem.maStrFilter;
if ( rItem.pImpl->pGraphicObject )
{
@@ -3852,7 +3856,7 @@ int SvxBrushItem::operator==( const SfxPoolItem& rAttr ) const
{
if ( GPOS_NONE != eGraphicPos )
{
- bEqual = maStrLink == rCmp.maStrLink;
+ bEqual = maStrLink == rCmp.maStrLink && maReferer == rCmp.maReferer;
if ( bEqual )
{
@@ -3943,6 +3947,9 @@ const GraphicObject* SvxBrushItem::GetGraphicObject() const
if ( bLoadAgain && !maStrLink.isEmpty() && !pImpl->pGraphicObject )
// when graphics already loaded, use as a cache
{
+ if (SvtSecurityOptions().isUntrustedReferer(maReferer)) {
+ return 0;
+ }
pImpl->pStream = utl::UcbStreamHelper::CreateStream( maStrLink, STREAM_STD_READ );
if( pImpl->pStream && !pImpl->pStream->GetError() )
{
@@ -3991,6 +3998,7 @@ void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew )
{
DELETEZ( pImpl->pGraphicObject );
maStrLink = "";
+ maReferer = "";
maStrFilter = "";
}
else
diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx
index 2dca4a74d332..e4a9bb996092 100644
--- a/editeng/source/items/numitem.cxx
+++ b/editeng/source/items/numitem.cxx
@@ -424,7 +424,7 @@ void SvxNumberFormat::SetGraphic( const OUString& rName )
return ;
delete pGraphicBrush;
- pGraphicBrush = new SvxBrushItem( rName, "", GPOS_AREA, 0 );
+ pGraphicBrush = new SvxBrushItem( rName, ""/*TODO?*/, "", GPOS_AREA, 0 );
pGraphicBrush->SetDoneLink( STATIC_LINK( this, SvxNumberFormat, GraphicArrived) );
if( eVertOrient == text::VertOrientation::NONE )
eVertOrient = text::VertOrientation::TOP;