@@ -106,8 +106,11 @@ void ImageLoader::Initialize(React::ReactContext const &reactContext) noexcept {
106106void ImageLoader::getSize (std::string uri, React::ReactPromise<std::vector<double >> &&result) noexcept {
107107 // VALIDATE URI - file:// abuse PROTECTION (P0 Critical - CVSS 7.8)
108108 try {
109- // Allow data: URIs and http/https only
110- if (uri.find (" data:" ) != 0 ) {
109+ if (uri.find (" data:" ) ==
110+ 0 ) { // Validate data URI size to prevent DoS through memory exhaustion
111+ // ::Microsoft::ReactNative::InputValidation::SizeValidator::ValidateSize( uri.length(),
112+ // ::Microsoft::ReactNative::InputValidation::SizeValidator::MAX_DATA_URI_SIZE, "Data URI"); }
113+ // else {
111114 ::Microsoft::ReactNative::InputValidation::URLValidator::ValidateURL (uri, {" http" , " https" });
112115 }
113116 } catch (const ::Microsoft::ReactNative::InputValidation::ValidationException &ex) {
@@ -140,8 +143,11 @@ void ImageLoader::getSizeWithHeaders(
140143 &&result) noexcept {
141144 // SDL Compliance: Validate URI for SSRF (P0 Critical - CVSS 7.8)
142145 try {
143- // Allow data: URIs and http/https only
144- if (uri.find (" data:" ) != 0 ) {
146+ if (uri.find (" data:" ) ==
147+ 0 ) { // Validate data URI size to prevent DoS through memory exhaustion
148+ // ::Microsoft::ReactNative::InputValidation::SizeValidator::ValidateSize( uri.length(),
149+ // ::Microsoft::ReactNative::InputValidation::SizeValidator::MAX_DATA_URI_SIZE, "Data URI"); }
150+ // else {
145151 ::Microsoft::ReactNative::InputValidation::URLValidator::ValidateURL (uri, {" http" , " https" });
146152 }
147153 } catch (const ::Microsoft::ReactNative::InputValidation::ValidationException &ex) {
@@ -172,8 +178,11 @@ void ImageLoader::getSizeWithHeaders(
172178void ImageLoader::prefetchImage (std::string uri, React::ReactPromise<bool > &&result) noexcept {
173179 // VALIDATE URI - file:// abuse PROTECTION (P0 Critical - CVSS 7.8)
174180 try {
175- // Allow data: URIs and http/https only
176- if (uri.find (" data:" ) != 0 ) {
181+ if (uri.find (" data:" ) ==
182+ 0 ) { // Validate data URI size to prevent DoS through memory exhaustion
183+ // ::Microsoft::ReactNative::InputValidation::SizeValidator::ValidateSize( uri.length(),
184+ // ::Microsoft::ReactNative::InputValidation::SizeValidator::MAX_DATA_URI_SIZE, "Data URI"); }
185+ // else {
177186 ::Microsoft::ReactNative::InputValidation::URLValidator::ValidateURL (uri, {" http" , " https" });
178187 }
179188 } catch (const ::Microsoft::ReactNative::InputValidation::ValidationException &ex) {
@@ -192,8 +201,11 @@ void ImageLoader::prefetchImageWithMetadata(
192201 React::ReactPromise<bool > &&result) noexcept {
193202 // SDL Compliance: Validate URI for SSRF (P0 Critical - CVSS 7.8)
194203 try {
195- // Allow data: URIs and http/https only
196- if (uri.find (" data:" ) != 0 ) {
204+ if (uri.find (" data:" ) ==
205+ 0 ) { // Validate data URI size to prevent DoS through memory exhaustion
206+ // ::Microsoft::ReactNative::InputValidation::SizeValidator::ValidateSize( uri.length(),
207+ // ::Microsoft::ReactNative::InputValidation::SizeValidator::MAX_DATA_URI_SIZE, "Data URI"); }
208+ // else {
197209 ::Microsoft::ReactNative::InputValidation::URLValidator::ValidateURL (uri, {" http" , " https" });
198210 }
199211 } catch (const ::Microsoft::ReactNative::InputValidation::ValidationException &ex) {
0 commit comments