在 Bug 赏金计划中可能让你付出高昂代价的 10 段 JavaScript

admin 2024年1月21日16:29:47评论5 views字数 1810阅读6分2秒阅读模式

在 Bug 赏金计划中可能让你付出高昂代价的 10 段 JavaScript

向 bug 赏金猎人教授 JavaScript 涉及到关注该语言及其生态系统中通常与安全漏洞相关的部分。以下是 10 个 JavaScript 代码片段示例,每个示例都突出显示了 bug 赏金猎人可能感兴趣的不同方面:

  1. 通过 InnerHTML 的跨站脚本 (XSS)

    // Vulnerable to XSS if 'userInput' is not sanitizeddocument.getElementById('someElement').innerHTML = userInput;
  2. 通过 URL 操作进行基于 DOM 的 XSS

    // Vulnerable to DOM-based XSS if URL parameters are not properly handledvar userData = window.location.href.substring(window.location.href.indexOf("user=") + 5);document.getElementById('userDisplay').innerText = userData;
  3. 通过 eval() 进行 JavaScript 注入

    // Dangerous use of eval() with user-provided datavar userCode = getUserInput();eval(userCode);
  4. 原型污染

    // Vulnerable to prototype pollutionfunction mergeOptions(obj1, obj2) {   for (var prop in obj2) {       if (obj2.hasOwnProperty(prop)) {           obj1[prop] = obj2[prop];       }   }}
  5. 不安全的直接对象引用 (IDOR)

    // Using user input directly in an important operationvar userId = document.getElementById('userId').value;var userData = getUserData(userId); // Potential IDOR if not properly checked
  6. 客户端逻辑操作

    // Relying on client-side validation for important logicif (clientSideCheckPassed()) {   completeTransaction();}
  7. 本地存储中的敏感数据暴露

    // Storing sensitive data in local storagelocalStorage.setItem('sessionToken', sessionToken);
  8. 不安全的 CORS 政策

    // Setting a too permissive CORS policyapp.use((req, res, next) => { res.setHeader('Access-Control-Allow-Origin', '*'); next();});
  9. 将 document.write 与用户输入一起使用

    // Potential XSS vulnerability with document.writevar userInput = getUrlParameter("userInput"); // Assuming this function gets user input from URLdocument.write(userInput);
  10. 错误处理不当泄露敏感信息

    // Insecure error handling that could reveal sensitive informationtry {    performSensitiveOperation();} catch (error) {    console.log('Error:', error); // Logging detailed error information}

这些示例中的每一个都代表了 JavaScript 编码中可能导致漏洞的常见问题。漏洞赏金猎人应该熟悉这些模式,以便有效地识别和报告潜在的安全问题。

原文地址:

https://blog.hackxpert.com/2024/01/10-pieces-of-javascript-that-could-cost-you-dearly-in-a-bug-bounty-program

原文始发于微信公众号(Ots安全):在 Bug 赏金计划中可能让你付出高昂代价的 10 段 JavaScript

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年1月21日16:29:47
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   在 Bug 赏金计划中可能让你付出高昂代价的 10 段 JavaScripthttps://cn-sec.com/archives/2414366.html

发表评论

匿名网友 填写信息