icann / icann-rdap

ICANN implementation of the Registry Data Access Protocol (RDAP)
Apache License 2.0
15 stars 4 forks source link

Internal Server Error for IP query in X.X.X/24 format #11

Closed jumpifnotzero closed 1 year ago

jumpifnotzero commented 1 year ago

Query for /ip/229.0.0/24 causes an error in the logs

2023-06-05T21:17:56.420225Z ERROR tower_http::trace::on_failure: response failed classification=Status code: 500 Internal Server Error latency=0 ms

Interestingly, I used the 224.0.0/24 to create the data (rdap-srv-data network --cidr 224.0.0/24).

I don't think it is related, but server has objects for 224.0.0.7/32, 224.0.0.0/24 and 224.0.0.0/8.

anewton1998 commented 1 year ago

So that I understand, the issue is that the IP address portion of the cidr only had 3 octets instead of 4? Did you use the rdap command to issue the query or something like curl?

anewton1998 commented 1 year ago

Doh! I see the issue right here: https://github.com/icann/icann-rdap/blob/3407761ba4a5baf6a4b6ffc5317d456d2de2e6ad/icann-rdap-srv/src/rdap/ip.rs#L25

The server is checking if the input is in CIDR form, but not passing in the canonical CIDR to the storage engine. cidr_utils::IpCidr is quite liberal in what it accepts, and so "229.0.0/24" will yield true on is_ip_cidr() but that may cause an error in the backend storage.

anewton1998 commented 1 year ago

Fixed in commit f9598ead8a1bc993abd930edf3e3e4c661900455 when it is merged.

anewton1998 commented 1 year ago

Merged in #20