Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use "mount all" when a container exists with a $ sign in the name (like "$web") #1630

Open
angrygreenfrogs opened this issue Feb 12, 2025 · 4 comments
Assignees
Milestone

Comments

@angrygreenfrogs
Copy link

We have a storage account that has a container named "$web" within it.

I believe this is very simply an issue where something is probably catching "$web" and interpreting it as a variable rather than being properly escaped.

Configuration

vi /etc/blobfuse2/config.yaml
#
# Refer ./setup/baseConfig.yaml for full set of config parameters
logging:
  type: syslog
  level: log_debug

components:
  - libfuse
  - file_cache
  - attr_cache
  - azstorage

libfuse:
  attribute-expiration-sec: 120
  entry-expiration-sec: 120
  negative-entry-expiration-sec: 240

file_cache:
  path: /mnt/blobfuse2tmp
  timeout-sec: 120
  max-size-mb: 4096

attr_cache:
  timeout-sec: 7200

azstorage:
  type: block
  account-name: MYACCOUNT
  sas: MYSAS
  mode: sas
#  

Test commands

mkdir ./test
blobfuse2 mount all ./test --read-only=true --config-file=/etc/blobfuse2/config.yaml

Result

Mounting container : $web to path  test/$web
Failed to mount container $web : Error: invalid config file [open /root/.blobfuse2/config_.yaml: no such file or directory]

If you look in /root/.blobfuse2, you'll see these files:

total 20
drwxr-xr-x  2 root root 4096 Feb 13 01:47  ./
drwx------ 18 root root 4096 Feb 13 01:44  ../
-rw-r--r--  1 root root    4 Feb 13 01:47  _home_admin_k_inventory.pid
-rw-r--r--  1 root root  654 Feb 13 01:47 'config_$web.yaml'
-rw-r--r--  1 root root  669 Feb 13 01:47  config_inventory.yaml

The other container "inventory" mounts successfully.

As you can see above, blobfuse2 is complaining about "/root/.blobfuse2/config_.yaml" not existing, but there is a file called 'config_$web.yaml', so I bet $web is not being escaped in some internal command and results in a blank value being used.

@jainakanksha-msft
Copy link
Collaborator

@angrygreenfrogs, in blobfuse mount command, the config file name can be provided as a variable, and blobfuse resolve that variable first before running the command.
This is what's happening in your case.
$web is being considered a variable, which is being replaced by an empty value.
Are there any specific use case for using special character in your container name?

@angrygreenfrogs
Copy link
Author

Thanks for the reply!

Apologies, but I don't believe that's entirely accurate.... I'm with you that the problem in my case is that my "$web" container is being incorrectly interpreted as a variable (which is blank in the environment), but I still believe this is a bug.

I've even found that I can work-around this issue in a hacky way by exporting a variable with that name, which tricks the executed shell command into working

web='$web'
export web
blobfuse2 mount all ./test --read-only=true --config-file=/etc/blobfuse2/config.yaml

I've never really done much with Go, but I suspect the problem is inside mountAllContainers(), which calls updateCliParams() to process CLI parameters that are called with exec.Command to execute the individual mount commands.

I believe this is simply a lack of escaping the parameters correctly - effectively allowing a shell injection issue.

It's not uncommon to have container names like $web - that's the default container name used by Azure for serving static web content from a storage container (which is what our container is being used for).

For example: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website

@jainakanksha-msft
Copy link
Collaborator

This failure not only comes with mountall command.
Even the command blobfuse2 mount ./test --read-only=true --config-file=/home/abc/.blobfuse2/config_$web.yaml also fails.
Reason being we resolve all the variables while evaluating the value of config_file.

@vibhansa-msft
Copy link
Member

in case of mount all you have an option to exclude certain containers from mounting, did you try using that ?

@vibhansa-msft vibhansa-msft added this to the v2-2.5.0 milestone Feb 13, 2025
@vibhansa-msft vibhansa-msft self-assigned this Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants