@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Rate limit outbound requests in Macros

Summary:
Ref T6755. Although we do not return response bodies, it is possible to perform crude portscanning if you can execute a DNS rebinding attack (which, for now, remains theoretical).

Limit users to 60 requests / hour to make it less feasible. This would require ~30 years to portscan all ports on a `/32` netblock.

Users who can guess that services may exist can confirm their existence more quickly than this, but if the attacker already had a very small set of candidate services it seems unlikely that portscanning would be of much use in executing the attack.

This protection should eventually be applied to T4190, too (that task also has other considerations).

Test Plan: Set rate limit very low, hit rate limit.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6755

Differential Revision: https://secure.phabricator.com/D12168

+31
+2
src/__phutil_library_map__.php
··· 1844 1844 'PhabricatorFilesManagementPurgeWorkflow' => 'applications/files/management/PhabricatorFilesManagementPurgeWorkflow.php', 1845 1845 'PhabricatorFilesManagementRebuildWorkflow' => 'applications/files/management/PhabricatorFilesManagementRebuildWorkflow.php', 1846 1846 'PhabricatorFilesManagementWorkflow' => 'applications/files/management/PhabricatorFilesManagementWorkflow.php', 1847 + 'PhabricatorFilesOutboundRequestAction' => 'applications/files/action/PhabricatorFilesOutboundRequestAction.php', 1847 1848 'PhabricatorFlag' => 'applications/flag/storage/PhabricatorFlag.php', 1848 1849 'PhabricatorFlagColor' => 'applications/flag/constants/PhabricatorFlagColor.php', 1849 1850 'PhabricatorFlagConstants' => 'applications/flag/constants/PhabricatorFlagConstants.php', ··· 5160 5161 'PhabricatorFilesManagementPurgeWorkflow' => 'PhabricatorFilesManagementWorkflow', 5161 5162 'PhabricatorFilesManagementRebuildWorkflow' => 'PhabricatorFilesManagementWorkflow', 5162 5163 'PhabricatorFilesManagementWorkflow' => 'PhabricatorManagementWorkflow', 5164 + 'PhabricatorFilesOutboundRequestAction' => 'PhabricatorSystemAction', 5163 5165 'PhabricatorFlag' => array( 5164 5166 'PhabricatorFlagDAO', 5165 5167 'PhabricatorPolicyInterface',
+22
src/applications/files/action/PhabricatorFilesOutboundRequestAction.php
··· 1 + <?php 2 + 3 + final class PhabricatorFilesOutboundRequestAction 4 + extends PhabricatorSystemAction { 5 + 6 + const TYPECONST = 'files.outbound'; 7 + 8 + public function getActionConstant() { 9 + return self::TYPECONST; 10 + } 11 + 12 + public function getScoreThreshold() { 13 + return 60 / phutil_units('1 hour in seconds'); 14 + } 15 + 16 + public function getLimitExplanation() { 17 + return pht( 18 + 'You have initiated too many outbound requests to fetch remote URIs '. 19 + 'recently.'); 20 + } 21 + 22 + }
+7
src/applications/macro/controller/PhabricatorMacroEditController.php
··· 72 72 )); 73 73 } else if ($uri) { 74 74 try { 75 + // Rate limit outbound fetches to make this mechanism less useful for 76 + // scanning networks and ports. 77 + PhabricatorSystemActionEngine::willTakeAction( 78 + array($user->getPHID()), 79 + new PhabricatorFilesOutboundRequestAction(), 80 + 1); 81 + 75 82 $file = PhabricatorFile::newFromFileDownload( 76 83 $uri, 77 84 array(