SslLibrary crashes with unhandled OSError: port/proto not found on non-standard SSL ports
Maintainers usually reply within 1 day
@himanchalkaushale is already working on this.
Since Nov 13, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start with nettacker/core/lib/ssl.py and compare its three service lookups with the fallback in nettacker/core/lib/socket.py:51-54; then read tests/unit/core/lib/test_ssl.py. Run the SSL unit tests and add regression coverage for unmapped ports in both scan paths, including the unknown fallback. Done when non-standard ports no longer raise and standard-port behavior remains unchanged.
Written by the indexing model from the issue text.
Description
Summary
SslLibrary.ssl_certificate_scan() and SslLibrary.ssl_version_and_cipher_scan() in nettacker/core/lib/ssl.py raise an unhandled OSError: port/proto not found when scanning SSL services on non-standard ports such as 8443, 9443, 4443, 8080, and 10443.
This occurs because socket.getservbyport() cannot resolve ports that are not registered in the system's services database. As a result, SSL scans on these ports silently fail instead of returning certificate and cipher information.
Current Behavior
Three locations in nettacker/core/lib/ssl.py (lines 166, 206, and 211) call:
"service": socket.getservbyport(int(port))
When the requested port has no registered service name, Python raises:
OSError: port/proto not found
In BaseEngine.run(), this exception is caught by the generic retry handler, resulting in response = [].
Consequently, SSL certificate and cipher scans may return empty results without reporting certificate details, expiration dates, or related vulnerabilities.
Expected Behavior
SSL scans should handle service lookup failures gracefully.
If socket.getservbyport() raises OSError, the service name should fall back to "unknown", allowing the SSL scan to continue.
This would also align with the existing fallback implementation in nettacker/core/lib/socket.py:51-54:
try:
service = socket.getservbyport(port)
except OSError:
service = "unknown"
Root Cause
socket.getservbyport() raises OSError when a port is not registered in the operating system's services database.
Although nettacker/core/lib/socket.py already handles this case, nettacker/core/lib/ssl.py performs three service lookups without exception handling.
Additionally, tests/unit/core/lib/test_ssl.py uses PORT = 80 in connection_params, which does not expose the issue with unmapped ports.
Steps to Reproduce
Run an SSL certificate scan against a host serving HTTPS on port 8443:
poetry run nettacker -i example.com -m ssl_certificate_scan -g 8443
Observe that the SSL scan returns no certificate results because the service lookup raises an exception that is subsequently swallowed by the engine's retry handler.
The underlying issue can also be reproduced independently:
import socket
socket.getservbyport(8443)
# OSError: port/proto not found
Proposed Solution
Introduce a helper in nettacker/core/lib/ssl.py to handle unmapped service ports:
def get_service_name(port):
try:
return socket.getservbyport(int(port))
except OSError:
return "unknown"
Replace the three direct socket.getservbyport(int(port)) calls at lines 166, 206, and 211 with this helper.
This would ensure that an unavailable service-name mapping does not interrupt SSL scanning.
Testing
Add regression tests in tests/unit/core/lib/test_ssl.py covering:
- SSL certificate scanning on port
8443without mockingsocket.getservbyport(), verifying that the unmapped port is handled gracefully. - The service name falls back to
"unknown"when the lookup raisesOSError. - Both certificate and version/cipher scanning paths handle unmapped ports without failing.
- Existing behavior for standard ports remains unchanged.
Additional Context
- Affected file:
nettacker/core/lib/ssl.py - Affected methods:
ssl_certificate_scan()andssl_version_and_cipher_scan() - Affected locations: Lines 166, 206, and 211
- Existing fallback implementation:
nettacker/core/lib/socket.py:51-54 - Existing tests:
tests/unit/core/lib/test_ssl.py
This issue is specific to service-name resolution and should not require changes to the underlying SSL certificate or cipher scanning logic.
- Dominant language
- Python
- Stars
- 5.7k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 12
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OWASP/Nettacker
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Hindi (hi.yaml) is missing 29 translation keys, can I add them?Possibly taken @shivanshuagrwl claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OWASP/Nettacker#1876 · 1 reaction · 1 assignee ·
Maintainers usually reply within 1 day
-
Use time.perf_counter() for HTTP response-time measurementsPossibly taken @29rdx claimed this 3 days ago. Openlow priority
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OWASP/Nettacker#1859 · 2 comments ·
Maintainers usually reply within 1 day
-
Fix remove_old_logs() failing to delete stale scan events when scan_compare_id is NonePossibly taken @himanchalkaushale claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OWASP/Nettacker#1856 · 5 comments ·
Maintainers usually reply within 1 day
-
admin_scan reports the homepage as an admin pagePossibly taken @Alfa-Dev404 claimed this 7 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OWASP/Nettacker#1850 · 1 comment · 1 reaction · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 78/100
splunk/security_content#4418 ·
Maintainers usually reply within 1 day
-
[Bug / Enhancement]: Improve teleop_robot CLI with configurable timeout, robust input validation, and clean ROS shutdownPossibly taken @muskan-creates352 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
-
bug(pipelines): shortcode stripping deletes text between a {{< >}} shortcode and the next {{% %}}Possibly taken @Ashborne-lab claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
kubeflow/docs-agent#293 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Imbad0202/academic-research-skills#1093 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pierreaubert/gpui-toolkit#114 ·
Maintainers usually reply within 1 day