`abuseipdb` output plugin crashes (and silently skips its rate-limit sleep) on an HTTP-date-formatted `Retry-After` header
Describe the bug
src/cowrie/output/abuseipdb.py's Reporter.rate_limit_handler()
parses a Retry-After response header with retry = int(retry.pop()).
HTTP allows Retry-After to be given either as
delta-seconds (an integer) or as an HTTP-date string (RFC 9110
section 10.2.3, formerly RFC 7231); AbuseIPDB's API is not documented
as using the date form, but nothing in this code rules it out, and the
plugin has no fallback for it. If a date-formatted header were ever
received, int() raises ValueError uncaught inside a
@defer.inlineCallbacks generator whose returned Deferred is never
consumed by its caller -- so the failure surfaces only as an unhandled
error in a Deferred, not a session crash, but with a worse practical
effect: the rate-limit sleep logic below the failing line (setting
logbook.sleeping, scheduling the wake-up call) never runs, so the
plugin silently keeps reporting IPs to AbuseIPDB past the point it was
told to back off.
To Reproduce Steps to reproduce the behavior:
- Call
int(retry.pop())(asrate_limit_handler()does) with aRetry-Afterheader value in HTTP-date form, e.g."Fri, 31 Dec 2026 23:59:59 GMT", instead of a plain integer. - Observe an uncaught
ValueError: invalid literal for int() with base 10: 'Fri, 31 Dec 2026 23:59:59 GMT'.
Reproduced directly against the parsing expression with a date-formatted
value, confirming the ValueError; after the fix, both the
delta-seconds and HTTP-date forms parse correctly into a seconds-until-
retry value.
Expected behavior
Either valid form of Retry-After (delta-seconds or HTTP-date) should
be parsed correctly so the plugin actually honors the rate limit it was
told about; an unparseable value should degrade to a logged failure
rather than raising.
Server (please complete the following information):
- OS: This bug is OS-independent (pure Python header parsing, no OS-specific code involved).
- Python: Python 3.14.2
- Twisted: Twisted 26.4.0
Additional context
- Cowrie Mode: Shell (default), any protocol -- affects the
output_abuseipdbplugin's own rate-limit compliance, not attacker sessions directly. - Honest caveat: it isn't confirmed live whether AbuseIPDB's API ever actually sends the HTTP-date form in practice; the fix is a defensive robustness improvement matching what the HTTP spec allows a server to send, and is harmless either way (the plain-integer form used today continues to parse exactly as before).
- Patched file:
src/cowrie/output/abuseipdb.py(Reporter.rate_limit_handler():int()is now tried first, with a fallback that parses an HTTP-date viaemail.utils.parsedate_to_datetimeand converts it to seconds remaining; an unparseable value now logs a failure and returns instead of raising).
Source: cowrie/cowrie