From: Roland Haeder Date: Fri, 22 May 2015 03:04:54 +0000 (+0200) Subject: *** Privacy Leak fixed: *** X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9c77425cf34bc266376e88f4ed16b626919f771e;p=quix0rs-gnu-social.git *** Privacy Leak fixed: *** - isCurrentProfileInScope() is now more asked if the current profile is allowed to see the given notice. It was possible (with upstream master) to see private messages in RSS and (possible) JSON feeds Signed-off-by: Roland Haeder --- diff --git a/actions/apisearchatom.php b/actions/apisearchatom.php index 18a1aa24cc..c1aa43483e 100644 --- a/actions/apisearchatom.php +++ b/actions/apisearchatom.php @@ -167,6 +167,12 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction if ($this->cnt > 0) { while ($notice->fetch()) { + // Check scope of notice to current profile (including guests) + if (!$notice->isCurrentProfileInScope()) { + // Not in scope + continue; + } + ++$cnt; if (!$this->max_id) { diff --git a/actions/apisearchjson.php b/actions/apisearchjson.php index 424773f12b..4b46109b98 100644 --- a/actions/apisearchjson.php +++ b/actions/apisearchjson.php @@ -118,7 +118,16 @@ class ApiSearchJSONAction extends ApiPrivateAuthAction $search_engine->limit(($this->page - 1) * $this->rpp, $this->rpp + 1); if ($search_engine->query($this->query)) { $cnt = $notice->find(); - $this->notices = $notice->fetchAll(); + foreach ($notice->fetchAll() as $testNotice) { + // Must be true + assert($testNotice instanceof Notice); + + // Check scope of notice to current profile (including guests) + if ($testNotice->isCurrentProfileInScope()) { + // In scope + $this->notices[] = $testNotice; + } + } // END - if } $this->showJsonTimeline($this->notices); diff --git a/actions/noticesearchrss.php b/actions/noticesearchrss.php index b12ea8de9c..f52d69dfdf 100644 --- a/actions/noticesearchrss.php +++ b/actions/noticesearchrss.php @@ -80,7 +80,11 @@ class NoticesearchrssAction extends Rss10Action if ($cnt > 0) { while ($notice->fetch()) { - $notices[] = clone($notice); + // Check scope of notice to current profile (including guests) + if ($notice->isCurrentProfileInScope()) { + // Is in scope + $notices[] = clone($notice); + } } } diff --git a/classes/Notice.php b/classes/Notice.php index 7b9cfd9e5b..15e50acbe0 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -2944,4 +2944,37 @@ class Notice extends Managed_DataObject $notice->_setReplies($ids); } } + + /** + * Checks whether the current profile is allowed (in scope) to see this notice. + * + * @return $inScope Whether the current profile is allowed to see this notice + */ + function isCurrentProfileInScope () { + // Check scope, default is allowed + $inScope = TRUE; + + //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] this->tag=' . $this->tag . ',this->id=' . $this->id . ',this->scope=' . $this->scope); + + // Is it private scope? + if ($this->isPrivateScope()) { + // 2) Get current profile + $profile = Profile::current(); + + // Is the profile not set? + if (!$profile instanceof Profile) { + // Public viewer shall not see a tag from a private dent (privacy leak) + //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] Not logged in (public view).'); + $inScope = FALSE; + } elseif (!$this->inScope($profile)) { + // Current profile is not in scope (not allowed to see) of notice + //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] profile->id=' . $profile->id . ' is not allowed to see this notice.'); + $inScope = FALSE; + } + } + + // Return result + //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] this->tag=' . $this->tag . ',this->weight=' . $this->weight . ',inScope=' . intval($inScope) . ' - EXIT!'); + return $inScope; + } } diff --git a/classes/Notice_tag.php b/classes/Notice_tag.php index d921b07594..78ef5136bd 100644 --- a/classes/Notice_tag.php +++ b/classes/Notice_tag.php @@ -107,21 +107,7 @@ class Notice_tag extends Managed_DataObject //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] this->tag=' . $this->tag . ',notice->id=' . $notice->id . ',notice->scope=' . $notice->scope); // Is it private scope? - if ($notice->isPrivateScope()) { - // 2) Get current profile - $profile = Profile::current(); - - // Is the profile not set? - if (!$profile instanceof Profile) { - // Public viewer shall not see a tag from a private dent (privacy leak) - //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] Not logged in (public view).'); - $inScope = FALSE; - } elseif (!$notice->inScope($profile)) { - // Current profile is not in scope (not allowed to see) of notice - //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] profile->id=' . $profile->id . ' is not allowed to see this tag.'); - $inScope = FALSE; - } - } + $inScope = $notice->isCurrentProfileInScope(); // Return result //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] this->tag=' . $this->tag . ',this->weight=' . $this->weight . ',inScope=' . intval($inScope) . ' - EXIT!'); diff --git a/lib/search_engines.php b/lib/search_engines.php index 7f1684a3e7..6014c89923 100644 --- a/lib/search_engines.php +++ b/lib/search_engines.php @@ -84,7 +84,6 @@ class MySQLSearch extends SearchEngine $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' . 'AGAINST (\''.$this->target->escape(strtolower($q)).'\' IN BOOLEAN MODE)', 'OR'); } - return true; } else if ('notice' === $this->table) { // Don't show imported notices @@ -100,10 +99,11 @@ class MySQLSearch extends SearchEngine 'AGAINST (\''.$this->target->escape($q).'\' IN BOOLEAN MODE)'); } - return true; } else { throw new ServerException('Unknown table: ' . $this->table); } + + return true; } } diff --git a/lib/tagcloudsection.php b/lib/tagcloudsection.php index 268540cf9b..5da138fd32 100644 --- a/lib/tagcloudsection.php +++ b/lib/tagcloudsection.php @@ -64,6 +64,7 @@ class TagCloudSection extends Section $sum = 0; while ($tags->fetch() && ++$cnt <= TAGS_PER_SECTION) { + // Check scope of tag to current profile (including guests) if ($tags->isCurrentProfileInScope()) { $tw[$tags->tag] = $tags->weight; $sum += $tags->weight;