Skip to content

exploiters: Fix extraction of container IP address - #15

Merged
razvand merged 1 commit into
mainfrom
razvand/fix/container-ip-address
Aug 25, 2026
Merged

exploiters: Fix extraction of container IP address#15
razvand merged 1 commit into
mainfrom
razvand/fix/container-ip-address

Conversation

@razvand

@razvand razvand commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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.

@razvand
razvand requested a review from AmaliaI12 August 7, 2026 15:48
@razvand razvand added the enhancement New feature or request label Aug 7, 2026
@razvand
razvand requested a lite review from Copilot August 7, 2026 15:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>.IPAddress instead of NetworkSettings.IPAddress.

馃挕 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread automatic_exploit_generation/exploiters/zeratool/zeratool.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_service raises, the container will be left running. Consider wrapping the request in a try/finally so 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>
@razvand
razvand force-pushed the razvand/fix/container-ip-address branch from a5789fc to fbadd5b Compare August 11, 2026 07:40
@razvand
razvand requested a lite review from Copilot August 11, 2026 07:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() in finally can raise and override the original exception (or even a successful return), making failures harder to diagnose. Cleanup in finally should 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 an IPAddress even if another network has one. This can cause false failures determining the container IP. Prefer iterating networks until a non-empty IPAddress is found (still preferring bridge).
            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 the finally block. If the first kill succeeds, the second kill may raise (e.g., container already stopped) and can interfere with the intended error path. The finally block 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.")

@ClaraStefania ClaraStefania left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works as expected.

@razvand
razvand merged commit 15301bf into main Aug 25, 2026
1 check passed
@razvand
razvand deleted the razvand/fix/container-ip-address branch August 25, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants