SSRF - Detection, Exploitation, and Mitigation Techniques [Part 1]

SSRF (Server Side Request Forgery) is a security vulnerability that allows an attacker to make unauthorized HTTP requests from the backend of a vulnerable web application by manipulating the URL/domain/path parameter of the request. The injected URL can come from either an internal network or a third-party network, and the attacker's goal is usually to gain unauthorized access to internal applications or leak sensitive data.

SSRF attacks can have serious consequences, such as unauthorized actions on third-party applications and remote command execution on vulnerable internal applications. Additionally, attackers can use SSRF to bypass network security measures such as firewalls and gain access to sensitive resources.

Detection techniques for pen-testing with different types of application scenarios

One of the most commonly used methods to detect SSRF vulnerabilities is to set up a dedicated server that can receive both DNS and HTTP requests. The idea is to identify requests made by the user-agent or originating from the IP address of the vulnerable application server. If the server receives a request from the application, it indicates that there might be an SSRF vulnerability present. This method can help in identifying SSRF attacks in real-time and is used extensively by security professionals and researchers. 

Another method of detecting SSRF attacks is based on response timing. In such cases, the attacker learns whether or not a specific resource exists based on the time it takes to receive a response. If the response time is significantly different from what is expected, it may indicate that the attacker is trying to access a resource that does not exist or is not accessible.

URL/domain/path as a part query string or request body - One common scenario where SSRF can occur is when an application takes any URL, domain name, or file path as an input as part of the query string or request body, and the values of these parameters are used in backend processing. SSRF  can happen when an attacker is able to control the input parameters and can inject malicious URL/domain/path. For instance, an attacker could use an image URL or a link URL as input in template generation, or use a file/directory path or an image URL in system/device configuration. In such cases, the attacker could trick the application into sending requests to internal resources or third-party services without the application's knowledge. The most common consequence of such attacks is unauthorized access to sensitive data or resources.

The Referrer header - This header can be manipulated by an attacker to exploit an SSRF vulnerability. If the application uses the referrer header for business logic or analytics purposes, the attacker can modify it to point to a target server they control. The vulnerable application will then make requests to the internal network, allowing them to potentially gain access to internal resources. This can also lead to data exfiltration or unauthorized actions on third-party applications.

PDF Rendering/Preview Functionality - If the application provides the ability to generate PDF files or preview their content based on user input data, there may be a risk of SSRF. This is because the application's code or libraries could render the user-supplied JavaScript content on the backend, potentially leading to SSRF vulnerabilities. Attackers could exploit this vulnerability by injecting a malicious URL or IP address in the PDF file or the preview content, resulting in unauthorized access to internal systems or sensitive data. Therefore, it's important for developers to thoroughly sanitize user input data and restrict access to internal resources to prevent SSRF attacks.

File uploads – If an application includes a file upload feature and the uploaded file is parsed or processed in any way, it may be vulnerable to SSRF attacks. This is because URLs or file paths embedded in uploaded files such as SVG, XML, or PDF files may be used to make unauthorized requests to external resources. Attackers can leverage this vulnerability to perform actions such as gaining unauthorized access to internal applications, leaking sensitive data, or executing commands on third-party applications through vulnerable application’s origin.

Bypassing Whitelisted Domain/URL/Path – An attacker can use various encoding mechanisms and supply malformed URL formats with binary characters for the localhost URL, including techniques like CIDR bypass, dot bypass, decimal/octal/hexadecimal bypass, and domain parser confusion, to evade an application's whitelisted URL/domain/file path configuration. This can allow the attacker to inject a malicious URL or domain name, potentially leading to an SSRF vulnerability.

Checking with different protocols/IP/Methods - An attacker may attempt to exploit an SSRF vulnerability by sending requests with different protocols (e.g. file, dict, sftp, gopher, LDAP, etc.), IP addresses, and HTTP methods (e.g. PUT, DELETE, etc.) to see if the application is vulnerable. For instance, an attacker may try to access internal resources using the file protocol, which can allow them to read files on the server or execute arbitrary code. Similarly, an attacker may try to access resources using less common protocols like dict or gopher, which are not typically used and may not be blocked by firewalls.

The upcoming section of the blog will delve deeper into the topic of SSRF exploitation in the context of cloud-based applications. We will also explore platform-oriented attacks on internal apps and examine various migration strategies to prevent SSRF attacks.

Article by Amish Shah


Lambda functions and CORS implications

CORS (Cross-Origin Resource Sharing) is a web browser security mechanism that restricts web pages from making cross-origin requests, adhering to the Same Origin Policy (SOP). When a web page from one origin requests a resource from another origin, the browser blocks the request unless the server hosting the requested resource explicitly allows it.

In the context of AWS Lambda functions, CORS security is crucial when developing serverless applications that interact with APIs hosted on different domains. Here are some important considerations to keep in mind while working with CORS and Lambda functions:

Set CORS headers properly: When your Lambda function returns a response, it should include the appropriate CORS headers to indicate which origins are allowed to access the resource. This is typically done using the Access-Control-Allow-Origin header, which specifies the domain(s) that are allowed to make requests.

Validate all inputs: To prevent malicious requests from bypassing CORS restrictions, it is important to validate all inputs to your Lambda function. This includes checking for invalid characters, input length limits, and other security checks.

Leverage API Gateway: API Gateway offers built-in support for CORS, allowing you to specify which origins are allowed to access your API. You can configure CORS settings at the API level or at the method level. 

Restrict access: You should limit access to your Lambda function to only the necessary resources and methods. This can be done using IAM (Identity and Access Management) policies to restrict access to specific resources or API methods. 

Having HTTPS: To prevent man-in-the-middle attacks, it is recommended to use HTTPS when making requests to your Lambda function. This will also help ensure that your CORS headers are not tampered with by an attacker.

By following these best practices, you can ensure that your Lambda function is secure and not vulnerable to CORS attacks.

Top Security issues with Lambda functions

AWS Lambda functions are a fundamental element of serverless computing across networks. In serverless architecture, the cloud provider manages the underlying infrastructure, including servers and scaling, while application developers focus on writing code for specific functions or tasks. Lambda functions are small code segments that can be executed in response to events such as data changes, user requests, or scheduled tasks. One of the primary advantages of using Lambda functions is that developers only pay for the time their code runs, which is more cost-effective than paying for a dedicated server or virtual machine. Additionally, the automatic scaling of Lambda functions makes it easier to handle unpredictable or fluctuating workloads. Lambda functions can be integrated with other AWS services such as Amazon S3, Amazon DynamoDB, and Amazon API Gateway to create complex and scalable applications. They can also be used to build microservices, which are small, independent components of an application that can be developed, deployed, and scaled independently. However, Lambda functions are also susceptible to security vulnerabilities. Here are ten critical issues that we have observed lately during our pen-testing:

  • Injection Attacks: Malicious inputs can be used to inject arbitrary code into Lambda functions.
  • Broken Access Controls: Weak or improper access controls can lead to unauthorized access to resources or data.
  • Insecure Storage of Secrets: Sensitive data or credentials stored insecurely within Lambda functions could be accessed by attackers.
  • Insecure Dependencies: Insecure or outdated dependencies can introduce vulnerabilities in Lambda functions.
  • Inadequate Authentication and Authorization: Weak authentication and authorization mechanisms can lead to unauthorized access to Lambda functions.
  • Improper Error Handling: Improper handling of errors in Lambda functions could leak sensitive information that could be exploited by attackers.
  • Insufficient Encryption: Lack of encryption can make data transmitted to or stored within Lambda functions vulnerable to interception and theft.
  • Lack of Monitoring and Logging: Without proper monitoring and logging, it can be difficult to detect and respond to security incidents.
  • Denial of Service Attacks: Malicious actors can use Lambda functions to perform Distributed Denial of Service (DDoS) attacks.
  • Insider Threats: Malicious actors with legitimate access to Lambda functions can exploit vulnerabilities to steal data or perform unauthorized actions.

[Case Study] Expanding Application Security Services through Strategic Partnership

Background
ACME, a leading application security provider, has established itself as a trusted name in the industry through its proprietary scanner and manual penetration testing services. With a majority of its business derived from its advanced scanner, ACME offers its customers a comprehensive application that provides seamless access to security testing results. The platform also enables pentesters to upload their findings manually or in XML/JSON format, ensuring flexibility and convenience for its users.

Challenges
As ACME continued to grow, the demand for on-demand manual penetration testing services increased significantly. Despite the efficiency of its scanner, ACME faced challenges in scaling its manual pen-testing services to meet the needs of its expanding customer base. To maintain its reputation for delivering high-quality, reliable results, ACME needed to ensure that its manual testing services could keep pace with the growing demand without compromising on quality.

Solution
To address this challenge, ACME reached out to Blueinfy known for delivering cutting-edge penetration testing services with exceptional accuracy. ACME sought to partner with Blueinfy to provide application penetration testing services to its customers, allowing ACME to scale effortlessly and ensure the availability of a skilled on-demand testing team when needed.

Implementation
ACME began sub-contracting its manual penetration testing work to Blueinfy, leveraging Blueinfy's expertise to enhance its service offerings. Recognizing the need for seamless integration between the two companies, Blueinfy developed a specialized tool that converts Word reports into XML/JSON formats, enabling ACME to easily import results into its application. This tool not only streamlined the reporting process but also ensured that ACME's customers continued to receive consistent, high-quality results. 

In addition to delivering accurate and detailed penetration testing reports, Blueinfy provided comprehensive support to ACME's customers. This included walkthrough calls to understand the application, as well as report readout sessions to ensure a thorough understanding of the results. Blueinfy's commitment to customer support further solidified the partnership, enhancing ACME's reputation for delivering exceptional service.

Results

The partnership between ACME and Blueinfy proved to be a resounding success. By outsourcing its manual penetration testing services to Blueinfy, ACME was able to expand its service offerings to existing customers while also attracting new business. The collaboration allowed ACME to scale its operations with ease, ensuring that it could meet the growing demand for high-quality manual testing services without compromising on the accuracy and reliability of its results.

Conclusion
The strategic partnership with Blueinfy enabled ACME to enhance its application security services, providing its customers with a comprehensive solution that combined the efficiency of its scanner with the precision of manual penetration testing. Blueinfy's expertise and commitment to quality played a pivotal role in ACME's success, allowing the company to expand its market presence and solidify its position as a leader in the application security industry.

Article by Hemil Shah

[Case Study] Enhancing Security for a Data Analytics SaaS Company

Client Overview
A data analytics SaaS company specializing in complex features such as data collectors, transformers, and multiple cloud integrations faced significant challenges in ensuring the security of its platform. The intricate nature of their system, combined with the need for a proper test environment and thorough understanding of the system, made security reviews particularly difficult.

Challenges

  • The platform included numerous data collectors and transformers, each requiring specific configurations and deep system knowledge to test effectively.
  • Multiple cloud environments needed to be set up accurately to mimic the production environment.
  • A lack of proper testing setups led to incomplete security reviews, making it difficult to identify and address potential vulnerabilities.
  • Automated scanners were insufficient to handle the platform’s complex workflows, often missing critical issues or generating false positives.


Blueinfy's Approach
Blueinfy was engaged to perform a thorough security review, leveraging its expertise in complex system testing. The approach included:

1. Documentation Review
Blueinfy began by meticulously reviewing the platform's documentation to gain a comprehensive understanding of the system’s architecture and features.
2. Cloud-Based Test Environments
The team set up cloud-based test environments that mirrored the production setup, ensuring accurate and relevant testing conditions.
3. Data Sets Loading and Configuration
Blueinfy loaded various data sets into the system and configured multiple data flows to simulate real-world usage, testing how the platform handled different scenarios.
4. Running Collectors and Engines
Various data collectors and engines were run to test the robustness and security of each feature, checking for potential vulnerabilities in the data flow and processing mechanisms.
5. Black-Box Penetration Testing
Blueinfy conducted black-box penetration testing on each feature, focusing on finding hidden vulnerabilities that could be exploited by attackers. The testing was designed to mimic potential attack vectors without prior knowledge of the internal workings of the system.


Results
The engagement led to the discovery of several critical and high-risk vulnerabilities that were previously undetected by automated scanners. Blueinfy provided a comprehensive report detailing these findings, along with actionable recommendations for remediation.

Comprehensive Report
The final report included a detailed analysis of the vulnerabilities, their potential impact, and step-by-step recommendations for fixing them.

Successful Remediation
The client implemented the recommended fixes, significantly enhancing the security of their platform.

Client Satisfaction
The company was highly satisfied with Blueinfy’s testing methodology, particularly noting that it outperformed automated scanners in dealing with the platform’s complex workflows.

Conclusion
Blueinfy’s thorough and methodical approach to security testing enabled the data analytics SaaS company to identify and remediate vulnerabilities that could have posed significant risks to their platform. The success of this engagement highlights Blueinfy’s capability to handle complex systems and provide tailored security solutions that go beyond standard automated testing tools.

Article by Amish Shah

[Case Study] Running and enhancing Application Security Program for an investment company

Company Overview
ACME is a prominent investment company with a diverse portfolio, spanning three major business lines and over 50 brands. The company sought to implement a robust global application security program to safeguard its digital assets and enhance its overall security posture.

Existing Security Program
ACME’s existing application security framework included:

  • Regular application penetration testing conducted by external vendors.
  • A program intended to manage and respond to reported vulnerabilities.
Despite these measures, ACME faced significant challenges:
  • The average time to resolve critical or high-risk vulnerabilities was 98 days.
  • The internal Application Security (AppSec) team consisted of only two members, one of whom left during the assessment period.


Challenges Identified
1. Inadequate Application pen testing quality
The external vendor’s application pen testing was more like a Dynamic Application Security Testing (DAST) scans which even did not effectively manage false positives, compromising the integrity of the pen-testing results. This resulted in push back from brands which was very obvious.  

2. VDP Scope Issues
The VDP program had inaccuracies in the domain list, and not all domains were included, resulting in incomplete vulnerability coverage. 

3. Communication Gaps
There was a lack of clear communication and follow-ups with Business Units (BUs), leading to delayed responses and unresolved vulnerabilities.

4. Absence of Management Reporting
ACME management did not receive comprehensive management reports, affecting the visibility of security issues and progress.

5. Incomplete Pen-Test Scope
The scope of pen-tests was sometimes incomplete, with certain domains omitted from the assessment.

Obviously, there seems to be huge gap in application security program and one can say, the program was not in good shape.

Strategic Approach by Blueinfy

To address these issues, Blueinfy was brought in to revamp ACME’s application security program with a strategic and multi-faceted approach:

1. Building Stronger BU Relationships

  • Blueinfy established direct communication channels with BUs to ensure that critical and high-risk vulnerabilities were addressed promptly.
  • Implemented a structured process to enforce vulnerability fixes, leading to a remarkable reduction in resolution times from 98 days to just 4 days within the first year.

2. Enhancing Pen-Test Quality

  • Worked closely with the existing vendor to improve the quality and accuracy of pen-test results. This included refining the DAST scanning process and ensuring effective management of false positives.

3. Refining VDP Scope

  • Corrected inaccuracies in the VDP domain list to ensure complete coverage of all relevant domains.
  • Updated the VDP program to include all necessary domains, enhancing vulnerability management.

4. Improving Communication and Documentation

  • Created comprehensive documentation, including policies and FAQs, to provide BUs with clear instructions and improve communication.
  • Implemented a robust follow-up mechanism to ensure timely resolution of vulnerabilities and effective coordination with BUs.

5. Scope Verification

  • Worked with BUs to confirm and refine the scope of pen-tests, ensuring that all relevant domains were included in the assessments.


Results Achieved
Significant Reduction in Resolution Time
The time to fix critical and high-risk vulnerabilities was reduced from 98 days to 4 days within the first year, demonstrating a substantial improvement in response efficiency.

Enhanced Pen-Test Quality
Improved the accuracy and reliability of pen-test results through better management of false positives and refined testing processes.

Complete VDP Coverage
Achieved accurate and comprehensive domain coverage in the VDP program, leading to more effective vulnerability management.

Better Communication and Documentation

Established clear guidelines and improved communication with BUs, facilitating faster resolution of security issues.

Scope Accuracy

Ensured that pen-test scopes were complete and accurate, covering all relevant domains.

Program Enhancement in the Second Year

To further advance ACME’s application security program, Blueinfy implemented the following measures:

1. Pen-Testing

  • Blueinfy took over the pen-testing process to deliver higher quality and more accurate results, leveraging Blueinfy’s expertise.


2. Quarterly DAST Scans

  • Established a quarterly DAST scanning program, including false positive removal, to ensure ongoing security assessment.


3. Risk-Based Approach to save cost

  • Implemented a risk-based approach, where high-risk applications were prioritized for pen-testing, and medium/low-risk applications were scanned using DAST.
  • Optimized resource allocation by focusing efforts on high-risk areas and utilizing automated scans for less critical assets.


4. Management Dashboard

  • Collaborated with ACME’s development team to create a management dashboard using Google Objects, providing better visibility and reporting on application security metrics.


5. On-Demand SAST Program

  • Implemented a Static Application Security Testing (SAST) program for on-demand code scanning, enhancing the ability to detect and address security issues early in the development process.


Conclusion

Through a combination of strategic improvements and tactical execution, Blueinfy successfully enhanced ACME’s global application security program. The comprehensive approach led to substantial reductions in vulnerability resolution times, improved quality of pen-testing and scanning, and better overall management of application security. The ongoing program enhancements have positioned ACME to effectively manage its security posture and respond proactively to emerging threats, ensuring a robust defense against potential vulnerabilities.

Article by Hemil Shah

[Case Study] Comprehensive Security Reviews in a Fast-Paced Financial Environment

Background
ACME, a leading financial sector company with multiple lines of business, has implemented a stringent security review program that mandates each application or implementation undergo a thorough security evaluation before being approved for production or go-live. This program is not just a compliance requirement but a critical measure to ensure the security and integrity of the firm’s diverse financial services, which cater to a vast and varied clientele. By maintaining this high standard, ACME continues to uphold its reputation as a secure and reliable financial institution.

Challenge
ACME operates in an extremely fast-paced development environment characterized by various development models, including custom-developed applications, third-party platforms for in-house apps, vendor applications with Single Sign-On (SSO) implementations, and frequent sprint releases. Each development type brings unique security challenges that require a tailored approach to testing, ensuring that all potential risks are addressed. Moreover, the complexity of coordinating between separate teams, managing pre-requisites, and ensuring the integrity of data across multiple departments further complicates the security review process. The need for seamless communication, precise planning, and the alignment of multiple stakeholders adds layers of difficulty in ensuring that security assessments are both comprehensive and timely.

Solution
To address these multifaceted challenges, ACME partnered with Blueinfy, entrusting them with the complete management of the security testing process from start to finish:

Pre-Requisites Sharing and Access Verification:
Blueinfy begins each engagement by ensuring that all necessary pre-requisites are thoroughly shared, and access to relevant systems is meticulously verified before any testing commences. This careful preparation is crucial for setting up a test environment that accurately mirrors the production environment, thereby ensuring that security assessments are realistic and reliable. By verifying access and prerequisites early, Blueinfy minimizes the risk of encountering delays or oversights during testing.

Scheduling Demos to Understand Applications/Implementations:
Before diving into the technical aspects of testing, Blueinfy schedules detailed demonstrations with ACME’s internal teams to gain a deep understanding of each application or implementation. These sessions are designed to uncover any unique functionalities, workflows, or potential vulnerabilities that might not be immediately apparent. This proactive approach ensures that the subsequent security testing is not just a box-checking exercise but a thorough examination tailored to the specific nuances of the application, increasing the likelihood of identifying any subtle or context-specific risks.

Scoping/Test Scenario Preparation:
Based on the understanding gained from these demos, Blueinfy meticulously narrows down the scope of the penetration test according to the nature of the changes being implemented. Whether it’s a full-blown penetration test, a limited scope assessment for specific enhancements, a client-side mobile application, API penetration test, or SSO implementation, the scope is carefully defined to match the specific needs of the project. This targeted approach not only ensures that the testing is highly relevant but also enables faster report delivery and more efficient budget utilization, aligning with ACME’s need for both speed and precision in their fast-paced environment.Thorough Penetration Testing:

Blueinfy’s penetration testing is both comprehensive and rigorous, combining the precision of automated tools with the nuanced insights of manual testing. The manual aspect of testing is particularly crucial, as it allows for the creation of custom-designed test cases that are directly aligned with the specific architecture and implementation details of each application. This dual approach ensures that both traditional vulnerabilities, such as SQL injection or XSS, and implementation-specific risks, are thoroughly vetted. The extensive nature of these tests ensures that no stone is left unturned in the pursuit of securing ACME’s applications.

Detailed Reporting:
Upon completing the security assessments, Blueinfy provides ACME with highly detailed reports, with zero false positives or false negatives that adhere to the firm’s stringent formatting and content requirements. These reports go beyond mere identification of vulnerabilities; they offer a comprehensive analysis that includes risk assessments, potential impact evaluations, and actionable recommendations for remediation. By delivering these insights in a clear and organized manner, Blueinfy empowers ACME’s teams to take swift and effective action, thereby reinforcing the firm’s overall security posture.

GRC Platform Integration:

To ensure that all findings are properly tracked and managed, Blueinfy seamlessly integrates the results of their security assessments into ACME’s Governance, Risk, and Compliance (GRC) platform. This integration allows for the efficient tracking of issues, timely closure of vulnerabilities, and streamlined approval processes. By embedding the findings directly into the GRC system, Blueinfy helps ACME maintain a cohesive and organized approach to risk management, ensuring that all security-related activities are thoroughly documented and easily accessible for future reference.

Management Reporting:
In addition to the technical reports, Blueinfy also provides ACME’s leadership with comprehensive management reports. These documents synthesize the outcomes of the security assessments, highlighting the unique findings identified in applications, key risk areas and offering strategic insights into the firm’s overall security posture. By presenting this high-level overview, Blueinfy enables ACME’s decision-makers to understand the broader implications of the security assessments, facilitating informed decision-making and strategic planning.

Outcome
Through its partnership with Blueinfy, ACME has achieved and maintained an exceptional security track record. After production, there have been virtually no vulnerabilities identified in annual penetration tests, production URL scans, or any other third-party assessments performed by ACME’s clients. This impeccable performance underscores the effectiveness of Blueinfy’s thorough and detailed approach to security testing. As a result, ACME continues to build and maintain trust with its clients, knowing that its applications are not only innovative but also secure, thereby reinforcing its position as a leader in the financial industry.

Article by Hemil Shah