box-builder / box

A mruby-based Builder for Docker Images
https://box-builder.github.io/box/
Other
238 stars 19 forks source link

bug: stacked `inside` statements cause relative path escape #256

Open erikh opened 7 years ago

erikh commented 7 years ago

This is not a security issue, just a bug in how we handle inside statements.

inside "/one" do
  inside "two" do
  end

  inside "three" do
  end
end

Right now, inside works with two but chdirs back to the workdir for three. I think this is caused by the inner end statement not handling its escape appropriately. This shouldn't be too hard to keep a stack for on the side so we can track it easier.

Workaround for now is to flatten inside statements and then use a constant/variable to scope each block, e.g.:

BUILD_DIR = "/one"

inside "#{BUILD_DIR}/two" do
end

inside "#{BUILD_DIR}/three" do
end