Getting started overview
This guide provides a focused walkthrough for initiating your use of the Mozilla HTTP scanner, also known as Mozilla Observatory. The process involves understanding its operational model, obtaining necessary credentials if using the API, and executing your initial scan. The Mozilla Observatory is primarily a web-based service with an accompanying API, allowing both manual and programmatic security assessments of websites. It focuses on analyzing HTTP/S configurations and headers to identify common security misconfigurations and vulnerabilities, offering recommendations based on current security best practices set by organizations like the World Wide Web Consortium on web security.
Before proceeding, it's helpful to review the Mozilla Observatory documentation to familiarize yourself with its capabilities and assessment methodology. The scanner evaluates various aspects, including Content Security Policy (CSP), HTTP Strict Transport Security (HSTS), X-Frame-Options, and other critical headers that contribute to a website's overall security posture. Understanding these components will aid in interpreting the scan results and implementing the recommended improvements.
The Mozilla HTTP scanner operates on a principles-based approach, providing scores and detailed explanations for each tested criterion. This transparency allows users to understand not just what issues exist, but also why they matter and how to resolve them. For instance, a low score on the Content Security Policy might indicate a lack of protection against cross-site scripting (XSS) attacks, with the report detailing specific directives to implement to mitigate this risk.
Here's a quick reference table outlining the steps to get started:
| Step | What to Do | Where |
|---|---|---|
| 1. Access the Scanner | Navigate to the Mozilla Observatory website or consider API usage. | Mozilla Observatory homepage |
| 2. Create Account / Get Keys | No account or API keys are strictly required for basic web use. For API access, understand that it's rate-limited and generally open. | Mozilla Observatory API documentation |
| 3. Make First Request | Enter a URL on the homepage or use the API endpoint with a target. | Mozilla Observatory homepage / API examples |
| 4. Review Results | Analyze the score and detailed recommendations provided. | On the website after scan / API response |
Create an account and get keys
The Mozilla HTTP scanner, via the Mozilla Observatory, does not require users to create an account or obtain API keys for its standard web-based usage. This design choice enables immediate and barrier-free access for individual website security checks. Users can simply visit the Mozilla Observatory homepage, enter a URL, and initiate a scan without any registration process.
For programmatic access through its API, the Mozilla Observatory also does not typically require API keys for general use. The API is designed for public access, allowing developers to integrate its scanning capabilities into their workflows or tools without needing to manage authentication tokens. This simplifies automation for tasks such as continuous integration/continuous deployment (CI/CD) pipelines or regular security audits. However, it's important to note that the API is subject to rate limiting to ensure fair usage and prevent abuse. Details on these limits are available within the Mozilla Observatory API documentation.
The absence of mandatory API keys differentiates Mozilla Observatory from many commercial security scanning services, which often gate access behind authentication mechanisms. This approach aligns with Mozilla's mission of an open and accessible internet, providing a valuable resource for web security practitioners globally. While this simplifies the getting started process, developers should still implement robust error handling in their applications to gracefully manage potential rate limit responses from the API.
Your first request
Making your first request with the Mozilla HTTP scanner can be done in two primary ways: via the web interface or programmatically through its API.
Web Interface Scan
- Navigate to the Homepage: Open your web browser and go to the Mozilla Observatory website.
- Enter URL: In the prominent input field on the homepage, type or paste the full URL of the website you wish to scan (e.g.,
https://example.com). - Initiate Scan: Click the 'Scan' button. The scanner will then process your request and display the results directly on the page.
The web interface provides an immediate visual representation of your website's security posture, including a letter grade (A+ through F) and detailed breakdowns of various security headers and configurations. Each item in the report is accompanied by a description of its importance and recommendations for improvement, making it suitable for quick assessments and manual analysis.
API Request
For automated scanning, you can interact with the Mozilla Observatory API. The API is RESTful and accepts HTTP GET requests. Here's an example using curl, a common command-line tool for making web requests:
curl -X GET "https://observatory.mozilla.org/api/v1/analyze?host=example.com"
Replace example.com with the domain you want to scan. The API will return a JSON object containing the scan results. A basic Python script could look like this:
import requests
import json
def scan_website(host):
api_url = f"https://observatory.mozilla.org/api/v1/analyze?host={host}"
try:
response = requests.get(api_url)
response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
data = response.json()
# Process the results
print(f"Scan results for {host}:")
print(json.dumps(data, indent=2))
# Example: Check the overall score
if 'score' in data:
print(f"Overall score: {data['score']}")
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err}") # e.g. 404, 500
except requests.exceptions.ConnectionError as conn_err:
print(f"Connection error occurred: {conn_err}") # e.g. DNS failure, refused connection
except requests.exceptions.Timeout as timeout_err:
print(f"Timeout error occurred: {timeout_err}")
except requests.exceptions.RequestException as req_err:
print(f"An unexpected error occurred: {req_err}")
# Example usage:
scan_website("apispine.com")
This script makes a GET request to the API and prints the JSON response. The requests library simplifies HTTP requests in Python. Ensure you have it installed (pip install requests). The API response will include a comprehensive set of data points, including a numerical score, individual test results, and recommendations, as detailed in the Mozilla Observatory API reference.
Common next steps
After successfully performing your initial scan with the Mozilla HTTP scanner, several common next steps can help you further secure your web assets and integrate the scanning process into your development lifecycle:
- Analyze and Prioritize Findings: Review the scan report thoroughly. The Mozilla Observatory provides detailed explanations for each finding, along with specific recommendations. Prioritize issues based on their severity and potential impact on your website's security. For example, a missing Strict-Transport-Security header might be a high priority for sites handling sensitive user data, as highlighted in Mozilla's documentation on HSTS.
- Implement Recommendations: Based on your analysis, begin implementing the suggested changes. This often involves modifying your web server configuration (e.g., Nginx, Apache) or application code to set appropriate HTTP headers, configure TLS/SSL correctly, or implement Content Security Policies.
- Rescan and Verify: After implementing changes, perform another scan of your website. This step is crucial to verify that the vulnerabilities have been addressed and that your security posture has improved. Continuously rescanning helps ensure that new deployments or configuration changes do not inadvertently introduce new issues.
- Integrate into CI/CD Pipelines: For development teams, integrating the Mozilla Observatory API into your continuous integration/continuous deployment (CI/CD) pipeline can automate security checks. This ensures that every code commit or deployment is automatically scanned for common security misconfigurations, providing early feedback and preventing insecure configurations from reaching production environments.
- Monitor Regularly: Web security is an ongoing process. Schedule regular scans (e.g., weekly or monthly) to continuously monitor your website's security. This helps detect any regressions or new vulnerabilities that might emerge due to updates in web standards or changes in your application's dependencies.
- Explore Advanced Features: The Mozilla Observatory documentation may offer insights into more advanced scanning options or interpretations of results. Understanding the nuances of each test can help in fine-tuning your security strategies.
By following these steps, you can move beyond a single scan to establish a proactive and continuous approach to web security, leveraging the Mozilla HTTP scanner as a key tool in your security toolkit.
Troubleshooting the first call
When making your first call to the Mozilla HTTP scanner, particularly through its API, you might encounter some common issues. Here are troubleshooting steps for typical scenarios:
- Network Connectivity Issues:
- Symptom: Connection refused, timeout errors, or inability to resolve the hostname.
- Solution: Verify your internet connection. If using
curlor a script, ensure there are no firewall rules blocking outbound connections toobservatory.mozilla.org. Check if the Mozilla Observatory service is operational by visiting its homepage directly in a browser.
- Incorrect URL/Host Format:
- Symptom: API returns an error indicating an invalid host or URL, or the web interface reports an unscanable site.
- Solution: Ensure the URL or host provided is correctly formatted. For the API, use the
hostparameter with just the domain (e.g.,example.com, nothttps://example.com). For the web interface, include the full protocol (https://orhttp://). Double-check for typos.
- Rate Limiting:
- Symptom: API returns a
429 Too Many Requestsstatus code. - Solution: The Mozilla Observatory API has rate limits. If you're making many requests in a short period, you might hit these limits. Implement a delay between requests or use exponential backoff for retries. Review the API documentation on rate limits for specific details.
- Symptom: API returns a
- DNS Resolution Problems:
- Symptom: The scanner cannot find the specified host, even if your local browser can access it.
- Solution: Ensure your domain's DNS records are correctly configured and propagated. Use tools like
nslookupordigto verify that your domain resolves to the correct IP address from various locations. Sometimes, newly configured domains take time to propagate globally.
- Server-Side Errors (5xx status codes):
- Symptom: The API returns a
5xxstatus code (e.g.,500 Internal Server Error,503 Service Unavailable). - Solution: These indicate an issue on the Mozilla Observatory's server. This is usually temporary. Wait a few minutes and try the request again. If the problem persists, check the Observatory's status or community forums if available.
- Symptom: The API returns a
- Invalid API Endpoint or Parameters:
- Symptom: API returns a
400 Bad Requestor404 Not Found. - Solution: Double-check the API endpoint and parameters against the Mozilla Observatory API documentation. Ensure you are using the correct version (e.g.,
/v1/analyze) and parameter names (e.g.,host).
- Symptom: API returns a
When troubleshooting, always consult the specific error messages returned by the API or displayed on the web interface, as they often provide direct clues about the underlying problem. Logging your requests and responses can also be invaluable for diagnosing issues.