exploiters: Fix extraction of container IP address - #15
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Docker container inspection logic used by the zeratool exploiter to retrieve the container鈥檚 IP address from the newer Docker inspection JSON structure.
Changes:
- Adjust container IP extraction to use
NetworkSettings.Networks.<network>.IPAddressinstead ofNetworkSettings.IPAddress.
馃挕 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3a069a2 to
a5789fc
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
automatic_exploit_generation/exploiters/zeratool/zeratool.py:91
container.kill()is only called after a successful gRPC request (and in the missing-IP branch). If_request_exploitation_to_grpc_serviceraises, the container will be left running. Consider wrapping the request in atry/finallyso the container is always terminated.
if not container_ip:
container.kill()
raise RuntimeError("Could not determine container IP address.")
exploit = self._request_exploitation_to_grpc_service(
container_ip, overflow_only, format_only, win_funcs
The current extraction of the container IP address is not robust. The IP address can be located in different parts in the JSON structure for the container runtime properties. Use a robust way to extract the IP address from the JSON schema that considers all possibilities of presenting the IP address. If the IP address cannot be retrieve, emit an error message and kill the container. Signed-off-by: Razvan Deaconescu <razvan.deaconescu@upb.ro>
a5789fc to
fbadd5b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (3)
automatic_exploit_generation/exploiters/zeratool/zeratool.py:98
- Unconditional
container.kill()infinallycan raise and override the original exception (or even a successful return), making failures harder to diagnose. Cleanup infinallyshould not be allowed to mask the main control flow; suppress/handle kill errors.
finally:
container.kill()
automatic_exploit_generation/exploiters/zeratool/zeratool.py:87
- When multiple networks are attached,
next(iter(networks.values()))may pick a network entry without anIPAddresseven if another network has one. This can cause false failures determining the container IP. Prefer iterating networks until a non-emptyIPAddressis found (still preferringbridge).
if "bridge" in networks:
container_ip = (networks.get("bridge", {}) or {}).get("IPAddress")
elif networks:
container_ip = (next(iter(networks.values())) or {}).get("IPAddress")
else:
automatic_exploit_generation/exploiters/zeratool/zeratool.py:90
container.kill()is called both here and again in thefinallyblock. If the first kill succeeds, the second kill may raise (e.g., container already stopped) and can interfere with the intended error path. Thefinallyblock already guarantees cleanup.
This issue also appears on line 97 of the same file.
if not container_ip:
container.kill()
raise RuntimeError("Could not determine container IP address.")
The JSON structure for the container IP address is not correct. Update to the current (potentially new) path in the JSON schema when inspecting a container.