privileged: ${VAR:-false} runs the container with --privileged
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start in podman_compose.py at container_to_args and inspect how the privileged value is converted into command-line arguments. Run the provided Compose-file reproduction against up and run; the fix is done when false-like interpolated values omit --privileged, while true-like values still enable it.
Written by the indexing model from the issue text.
Description
Hi! privileged: ${VAR:-false} ends up running the container with --privileged when VAR isn't set.
Interpolation turns the value into the string "false", and container_to_args only checks truthiness:
So any non-empty string, including "false" and "0", adds --privileged. It goes through the same builder for up and run. A plain YAML privileged: false works fine since that's a real bool.
To reproduce with podman-compose 1.6.0:
services:
app:
image: docker.io/library/alpine:3.20
command: ["true"]
privileged: ${PRIV:-false}
ctl_bool:
image: docker.io/library/alpine:3.20
command: ["true"]
privileged: false
With a stub podman that logs its arguments, podman-compose up -d and podman-compose run --rm app gave:
PRIV unset app: --privileged ctl_bool: no flag run app: --privileged
PRIV= app: --privileged ctl_bool: no flag run app: --privileged
PRIV=false app: --privileged ctl_bool: no flag run app: --privileged
PRIV=true app: --privileged ctl_bool: no flag run app: --privileged
I'd expect the first three to leave the flag off. Same code on main at 8063daed.
It's a security-relevant default since the container gets full privileges the user meant to turn off. The fix can reuse the existing try_parse_bool helper:
--- a/podman_compose.py
+++ b/podman_compose.py
@@ -1589,7 +1589,7 @@ async def container_to_args(
if cnt.get("tty"):
podman_args.append("--tty")
- if cnt.get("privileged"):
+ if try_parse_bool(cnt.get("privileged")) is True:
podman_args.append("--privileged")
if cnt.get("pid"):
podman_args.extend(["--pid", cnt["pid"]])
Happy to open a PR with a test if that helps!
- Dominant language
- Python
- Stars
- 6.3k
- Forks
- 647
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 5
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 containers/podman-compose
-
`pull` silently ignores unknown service names and exits 0Possibly taken @PacketBreaker claimed this 6 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
containers/podman-compose#1640 · 1 comment ·
Maintainers usually reply within 4 days
-
`name_separator_compat` also changes network names, which docker compose does not doPossibly taken @Eliot5566 claimed this 12 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
containers/podman-compose#1628 ·
Maintainers usually reply within 4 days
-
`extra_hosts` entries written as `HOSTNAME=IP` fail with "bad format for add-host"Possibly taken @Eliot5566 claimed this 18 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
containers/podman-compose#1620 ·
Maintainers usually reply within 4 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
containers/podman-compose#1619 · 3 comments · 1 reaction ·
Maintainers usually reply within 4 days
-
Support for services.attachPossibly taken @orshih6 claimed this 11 days ago. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
containers/podman-compose#1597 ·
Maintainers usually reply within 4 days
All issues in containers/podman-compose
Similar issues
-
docs(contributing): the two things that silently block a PRPossibly taken A pull request linked to this issue is open or already merged. Openavailable documentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 95/100
Nixitov/Riptide-Native#944 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
JTHCode/secretguard#24 ·
Maintainers usually reply within 1 day
-
area: middleware documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 ·
Maintainers usually reply within 1 day