Skip to content

Crash occurs when doing recursive scan against a directory that is denied access by AppArmor #125

@brlin-tw

Description

@brlin-tw

Steps to reproduce

  1. Launch an Ubuntu VM (I use this Vagrant-based VM implementation).

  2. Install vt to /usr/local/bin as root.

  3. Setting up an API key.

  4. Run the following command to create a directory to be denied by AppArmor:

    mkdir -p ~/denied-dir
  5. Create the /etc/apparmor.d/usr.local.bin.vt Apparmor profile file as root with the following content:

    abi <abi/3.0>,
    
    include <tunables/global>
    
    /usr/local/bin/vt {
    include <abstractions/base>
    include <abstractions/nameservice>
    include <abstractions/ssl_certs>
    
    /home/*/** r,
    deny owner /home/*/denied-dir/ r,
    
    /etc/hosts r,
    /etc/nsswitch.conf r,
    /run/systemd/resolve/stub-resolv.conf r,
    /usr/local/bin/vt mr,
    owner /home/*/.cache/.vt.relationships.cache rw,
    owner /home/*/.vt.toml rw,
    }
    
  6. Run the following command as root to load the AppArmor profile in enforcing mode:

    apparmor_parser -r /etc/apparmor.d/usr.local.bin.vt
  7. Run the following command to trigger the crash:

    vt scan file -r ~/denied-dir

Current behavior

The program crashed with:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x82be08]

goroutine 7 [running]:
github.com/VirusTotal/vt-cli/utils.(*StringArrayReader).ReadString(0x0?)
	/home/runner/work/vt-cli/vt-cli/utils/string_reader.go:46 +0x8
github.com/VirusTotal/vt-cli/utils.(*Coordinator).DoWithStringsFromReader.func1()
	/home/runner/work/vt-cli/vt-cli/utils/do.go:69 +0x2f
created by github.com/VirusTotal/vt-cli/utils.(*Coordinator).DoWithStringsFromReader in goroutine 1
	/home/runner/work/vt-cli/vt-cli/utils/do.go:68 +0x95

Expected behavior

No crash

Version

1.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions