Artifact Security
Artifacts are the main way users interact with Velociraptor. You launch an artifact collection against clients, and then collect the results on the Velociraptor server.
At its core, an artifact is a way to package VQL queries to make them easier to use.
For new users the number of artifacts can be overwhelming. Artifacts also
carry real power, so you need to control which users can access which
artifacts. This helps avoid mistakes due to inexperience. For example,
running a Windows.KapeFiles.Target collection as a large-scale hunt is
almost always a bad idea.
Most users develop their own operating procedures that specify:
- Which artifacts to use in which situation
- Who is allowed to launch more sensitive artifacts
- How artifacts are used (what type of arguments are allowed)
Velociraptor supports each of these goals.
For background on artifact types and the roles and permissions used here, see Artifact types and Roles and permissions.
Artifact security is complicated
Collecting sensitive forensic information from endpoints is a powerful
permission. The security measures described here are not
comprehensive. An investigator role has many escalation paths to take
over an endpoint, for example by acquiring lsass.exe memory or
downloading the SAM or NTDS.dit files.
Treat these restrictions as a best effort to avoid accidental errors. The true security boundary is the ability to collect artifacts at all.
Do not grant the investigator role to users you do not trust. Do not
grant the reader role to users you do not trust to view all collected
data, including PII and security sensitive data collected as part of the
forensic process.
Be especially careful when implementing SOAR-like functionality through the API. Extending the API to external programs increases the attack surface, especially if the SOAR application can schedule collections on endpoints. You can limit this risk by marking selected artifacts as basic.
Permissions used on this page
The rest of this page uses the following permissions:
| Permission | What it allows |
|---|---|
COLLECT_CLIENT |
Launch any client artifact, subject to required_permissions. |
COLLECT_BASIC |
Launch basic client and server artifacts. On a basic artifact, it also skips required_permissions. |
COLLECT_SERVER |
Launch non-basic server artifacts. Also required to configure event monitoring. |
NOTEBOOK_EDITOR |
Create and edit notebooks in the GUI, including running cells. VQL notebook functions use COLLECT_SERVER instead. |
ARTIFACT_WRITER |
Modify artifacts. Treat this permission as admin-equivalent. |
Hidden artifacts
The first goal is to reduce the number of artifacts presented in the GUI.
Velociraptor lets you customize artifacts and import large numbers of them
from external sources such as Artifact Packs, so a deployment can hold
hundreds or thousands of artifacts. Many have similar but different
functionality, which overwhelms users with too much choice and makes the
interface confusing.
To clean up the interface, Velociraptor lets you hide artifacts from the
GUI. A hidden artifact does not appear in the search functionality of the
artifact collection wizard or in the artifact list. The artifact still
exists, and it is visible in the output of the artifact_definitions()
plugin.
Visibility is stored in the artifact metadata, a field attached to each
artifact in the system. You hide or show an artifact with the
artifact_set_metadata() function.
Example: Making only certain artifacts visible
The following VQL hides all artifacts other than a selected set. Run it in a notebook:
LET VisibleArtifacts <= SELECT * FROM parse_csv(accessor="data",
filename='''Artifacts
Windows.Search.FileFinder
Windows.Forensics.Usn
Windows.NTFS.MFT
Generic.Client.Info
''')
SELECT name, name in VisibleArtifacts.Artifacts AS Visible
FROM artifact_definitions()
WHERE artifact_set_metadata(hidden=NOT name in VisibleArtifacts.Artifacts, name=name) OR TRUEOnly the listed artifacts then appear in the GUI.
This reduced view guides users toward preferred playbooks and procedures, which reduces confusion.
Basic artifacts
Hiding artifacts reduces clutter in the GUI, but it does not stop someone from launching them, for example with a VQL query. A hidden artifact is still available, only hidden. Hiding an artifact is not a security measure.
A user’s permissions control which actions they can take, both in the GUI and in a VQL query. Hiding an artifact does not restrict collection: a user who can collect an artifact can still collect it while it is hidden.
| Artifact visibility | User may collect | User may not collect |
|---|---|---|
| Visible | The artifact appears in the artifact picker and collection can succeed. | The artifact appears in the artifact picker, but collection is denied. |
| Hidden | The artifact does not appear in the artifact picker, but collection can still succeed through VQL or the API. | The artifact does not appear in the artifact picker, and collection is denied. |
Some artifacts are more dangerous than others and require more experienced operators. Velociraptor grants permissions through a Role, or you can add them directly to the user policy.
In this example the user has the Read Only role. This role does not let the user collect new artifacts from the endpoint, and it does not let the user update notebook cells, although they can read notebooks.
The user is also granted three permissions on top of that role:
- Label Clients: the user can change client labels.
- Collect Basic Client: despite the name, the user can collect basic
client and server artifacts.
COLLECT_BASICis a single permission and cannot be scoped to one artifact type. - Notebook Editor: the user can update notebook cells, and by extension evaluate VQL queries on the server.
If the user tries to collect an artifact that is not marked basic, the
request is denied because they do not have the COLLECT_CLIENT
permission.
COLLECT_BASIC is not limited to client artifacts. The same permission
lets the user launch any SERVER artifact marked basic, even if they do
not have COLLECT_SERVER.
You can still allow the user to collect selected artifacts that you consider safe:
LET BasicArtifacts <= SELECT * FROM parse_csv(accessor="data",
filename='''Artifacts
Generic.Client.Info
''')
SELECT name, name in BasicArtifacts.Artifacts AS Basic
FROM artifact_definitions()
WHERE artifact_set_metadata(basic=name in BasicArtifacts.Artifacts, name=name) OR TRUEGeneric.Client.Info is marked as basic, so this user can collect it.
The basic flag takes precedence over required_permissions. If the user
holds COLLECT_BASIC and the artifact is marked basic, the server does
not check the artifact’s required_permissions, even if the user also
holds COLLECT_CLIENT or COLLECT_SERVER.
COLLECT_BASIC covers client and server artifacts
COLLECT_BASIC is one permission. A user who holds it can launch every
basic client artifact and every basic SERVER artifact in the org.
You cannot grant it for client artifacts only or server artifacts only.
Marking a server artifact basic exposes it to every user with
COLLECT_BASIC, not only the users you intended.
The artifact must do its own safety checks. Do not use
required_permissions to limit who can launch a basic artifact.
Treat COLLECT_BASIC as a slightly trusted tier between the Read-Only User
and Investigator roles. It is not a way to grant one group of users access
to one set of basic artifacts and another group access to a different set.
If users need different access, the artifact itself must make that decision.
A basic server artifact should expose one well-defined operation and reject
anything else.
Controlling access to client artifacts
You can now combine hidden artifacts with basic artifacts to safely limit what a user can do.
Suppose you want to let a low-privilege user run ipconfig on a remote
system. You could give the user access to the Windows.System.CmdShell
artifact, which runs commands in the system shell. That is dangerous,
because the artifact accepts arbitrary commands and runs them on the
endpoint.
Instead, reduce the ways in which the Windows.System.CmdShell artifact
can be called by removing the user’s choice of artifact parameters.
Create a new artifact:
name: Custom.Ipconfig
sources:
- query: |
SELECT * FROM Artifact.Windows.System.CmdShell(Command="ipconfig")Because this artifact takes no parameters, the user cannot change the
command to anything other than ipconfig, which you consider safe to run
on any endpoint.
Adding the basic metadata to this artifact lets the user launch it,
without any ability to change the parameters or run arbitrary code.
You can use this approach to lock down a standard operating procedure:
- Velociraptor built-in artifacts are powerful and generic, and their actions are controlled by many parameters.
- You can write wrapper artifacts to narrow the available choices.
- Marking those artifacts as basic lets users run a reduced version of the artifact safely.
Allowing users to modify artifacts
Users with the ARTIFACT_WRITER permission can modify the artifact
itself. If a user can change the artifact, the access control described
here is bypassed.
Treat ARTIFACT_WRITER as admin equivalent, because a user with that
permission can escalate to full admin.
Restricting dangerous client artifacts
Users without the COLLECT_CLIENT permission can launch curated basic
artifacts. A user who has COLLECT_CLIENT can launch any client artifact.
The client then runs that artifact without any ACL enforcement. Not every
client artifact is equally safe.
Some client artifacts run arbitrary commands on the endpoint. The
Windows.System.CmdShell artifact, for example, runs arbitrary shell
commands, because the command to run is a user-supplied parameter passed
directly to the shell through the execve() plugin. An attacker can use
this for a complete domain compromise, for example by running a malicious
command on every asset in the environment.
The Windows.Sysinternals.Autoruns artifact also calls the execve()
plugin, but it sanitizes its arguments from user input.
An untrusted user may be allowed to collect Windows.Sysinternals.Autoruns,
but must be prevented from collecting Windows.System.CmdShell.
Because client artifacts have no ACL protection, artifact writers must be careful not to give users more permissions on the endpoint than intended.
Client artifacts can set the required_permissions field to make the
server check that the launching user holds those permissions before it
schedules the artifact. The server does not check this field when the
artifact is marked basic and the user holds COLLECT_BASIC. Use this
field to restrict collection of powerful, risky artifacts to
administrators.
Sanitize user input as far as possible to restrict the use of dangerous functions. For example:
-
When you use
execve(), build the command line so that user input cannot subvert or substantially edit the command that runs. -
When an artifact uses a plugin that writes to arbitrary files, such as
copy(), do not let the user specify the path and content of the files. Otherwise the user can write to startup locations and take over the endpoint. The same applies to writing registry keys, deleting files, and similar operations.
Safely using execve()
The execve() plugin launches external commands. It accepts a list of
parameters called argv instead of a single command line, and it
escapes individual arguments when necessary, so you do not need to
handle escaping yourself.
Do not launch commands through the shell:
SELECT * FROM execve(argv=["cmd.exe", "/c", "cacls " + DirectoryName])Run the target binary directly instead. Velociraptor escapes the command line when required.
SELECT * FROM execve(argv=["cacls.exe", DirectoryName])How do you know whether a client artifact gives extra permissions to
users? Velociraptor includes the artifact verifier, a static analyzer
that checks an artifact for problems. Among other things, it looks for
permissions that the artifact can use without declaring them. The artifact
editor runs it when you save, and shows anything it finds in a
Problems detected with artifact dialog, with an option to save anyway.
The artifacts verify command runs the same check from a terminal:
$ velociraptor -v artifacts verify ./content/exchange/artifacts/*
...
ERROR: Windows.Detection.RemoteIconForcedAuth: (0,0) required_permissions: Add EXECVE to artifact's required_permissions or implied_permissions fieldsThe artifact verifier checks every plugin and function in a CLIENT or
CLIENT_EVENT artifact and confirms that potentially dangerous permissions
appear in one of two fields:
-
required_permissionsrestricts who can launch the artifact. Only users who already hold that permission can launch it, so the artifact grants no additional permissions. The server checks this field when a user launches the artifact, so it applies to server artifacts as well as client artifacts. The exception is a basic artifact launched by a user withCOLLECT_BASIC. -
implied_permissionsrecords that the artifact can use a permission that the launching user does not need to hold. It does not restrict who can launch the artifact. Only the verifier reads it, so it has no effect on other artifact types.
A verifier warning does not stop the artifact from running, but the
artifacts verify command reports it as an error. The warning means the
artifact can use a permission that it does not declare, so anyone reading the
artifact cannot tell what it is able to do. The artifacts that ship with
Velociraptor are expected to be warning-free, and you can use them as a
reference. Resolve a warning by declaring the permission, or by
suppressing it with a reason.
Client artifact collection permissions model
When you collect client artifacts, these security features apply:
-
A user with neither the
COLLECT_CLIENTnor theCOLLECT_BASICpermission cannot collect any client artifact. -
A user with only the
COLLECT_BASICpermission can collect only artifacts markedbasic. -
A user with the
COLLECT_CLIENTpermission can collect any client artifact. The server checks the artifact’srequired_permissionsunless the user also holdsCOLLECT_BASICand the artifact is markedbasic. -
Artifacts with open-ended capabilities, such as running arbitrary commands, should list a restrictive
required_permissionsfield so that only users who already hold that permission can collect them. This prevents an artifact from granting additional permissions. -
Artifacts that can use a permission without depending on it should declare it in
implied_permissions. See Required vs implied permissions.
Required vs implied permissions
The two fields answer different questions, and only one of them controls who can run the artifact:
| Field | Question | Enforced? |
|---|---|---|
required_permissions |
Who may launch this artifact? | Yes, except basic artifacts for COLLECT_BASIC users |
implied_permissions |
What can this artifact use while it runs? | No, never |
required_permissions is the gate. The launching user must hold every
permission listed there before the server schedules the collection. The
exception is a basic artifact launched by a user with COLLECT_BASIC; the
server does not check the artifact’s required_permissions in that case.
implied_permissions is an acknowledgement to the verifier. It records that
the artifact can use the permission. It does not restrict who can launch the
artifact, and it does not change what the artifact can do.
The verifier treats every permission in required_permissions as implied as
well, so an artifact never needs to list the same permission in both fields.
When implied permissions are needed
The verifier reads the permissions that plugins and functions declare, not the
arguments a particular artifact passes to them. Some plugins declare a
permission whether or not the artifact actually uses it. query() declares
FILESYSTEM_WRITE even when the query only reads. winpmem() declares
FILESYSTEM_WRITE, but it only writes when the artifact sets image_path.
For example, Windows.Detection.Yara.PhysicalMemory never sets it, so the
write path never runs.
Without implied_permissions, the only ways to clear the warning would be to
over-restrict the artifact, requiring a permission that the user does not
need, or to leave a permanent warning in place. Neither is useful. The field
gives the author somewhere to say that the artifact can use the permission,
and why that is acceptable.
Declaring a permission
CLIENT and CLIENT_EVENT artifacts have a baseline of FILESYSTEM_READ
and MACHINE_STATE. The verifier treats these permissions as already
available to the artifact, so they never need to be declared, and it never
warns about them.
The baseline describes what the verifier expects, not what the user is granted. For example:
- An artifact that calls
info()never needs to declareMACHINE_STATE, because the baseline already covers it. - An artifact that runs arbitrary VQL, such as
Generic.Client.VQL, listsEXECVEinrequired_permissions, so only users who holdEXECVEcan launch it.
Other artifact types have no baseline, because the verifier only checks
permissions on CLIENT and CLIENT_EVENT artifacts. A SERVER artifact,
for example, can declare required_permissions, but implied_permissions
does nothing for it.
The verifier collects the permissions that the plugins and functions called
by the artifact’s VQL declare. It warns when a permission is neither one of
the baseline permissions nor declared in required_permissions or
implied_permissions. The warning suggests adding it to one of those fields,
and the field you choose determines whether the artifact restricts who can
run it:
-
The artifact needs the permission. Declare it in
required_permissions. The artifact then only works for users who already hold the permission, which is the right call when its job depends on the capability, such as running commands or writing files. -
The artifact can use the permission but does not need it. Declare it in
implied_permissions. The artifact stays available to every user who can launch it, and the declaration records that the artifact can use the capability. This fits a plugin that declares a permission for an argument the artifact never sets. -
The artifact should not have the permission at all. Change the VQL so that it no longer uses the capability, for example by using a plugin that only reads. Some environments do not tolerate the capability, and this is the only option that removes it.
Declaring a permission does not change what the artifact can do at runtime.
required_permissions narrows who can launch it, and implied_permissions
only records what the artifact can already use.
Example: Generic.Client.VQL
Generic.Client.VQL runs a VQL query supplied by the user, so it declares:
required_permissions:
- EXECVE
implied_permissions:
- IMPERSONATION
- FILESYSTEM_WRITEEXECVE is required because the artifact runs arbitrary VQL, which can
execute commands on the endpoint. Only users who already hold EXECVE may
launch it. IMPERSONATION and FILESYSTEM_WRITE are implied because
query() can switch principals and write files, but the artifact does not
depend on either capability.
Suppressing a permission warning
Sometimes a warning does not apply. A plugin may declare a permission that your artifact never actually uses, or a column name may shadow a function name. In those cases you can suppress the warning with a comment in any VQL block in the artifact:
// linter: required_permissions:"FILESYSTEM_WRITE"The comment applies to the whole artifact, wherever it appears. Wrap the
permission name in double quotes. The value is a regular expression, so
required_permissions:"FILESYSTEM_.*" suppresses every matching permission.
Prefer the exact permission.
Suppress a warning only when you can explain why it is wrong for this artifact:
- The diagnostic is a false positive. For example, a plugin declares a permission that the artifact never actually uses.
- Fixing it would change the artifact’s output. For example, renaming a column that shadows a plugin or function name changes the result schema.
- The artifact is third-party code that you cannot change.
A suppression says that the diagnostic does not apply. It is not a
replacement for implied_permissions, which says that the artifact can use
the capability. Use the declaration when the capability is real, and the
suppression when the warning is wrong.
Notebook artifacts
A NOTEBOOK artifact is a
notebook template. The notebooks
created from it are separate objects, and each one is independent of the
template once it has been created.
Creating a notebook in the GUI requires NOTEBOOK_EDITOR. The
notebook_create(), notebook_update(), and notebook_update_cell() VQL
functions require COLLECT_SERVER instead.
Running a cell checks the executing user’s permissions against the plugins
and functions in the cell. This happens every time a cell runs, including
cells that were added after the notebook was created. A user who can open
the notebook but does not hold MACHINE_STATE still cannot run
SELECT * FROM info() in a cell.
The verifier does not check the cells in a NOTEBOOK artifact or its
required_permissions. Defining this YAML field in such an artifact serves
no purpose.
Server artifacts and impersonation
Server and server event artifacts
A SERVER artifact uses required_permissions as a launch gate, the same
way a client artifact does: the user must hold every listed permission
before the server starts the artifact. Server.Utils.BackupDirectory, for
example, declares SERVER_ADMIN.
A basic SERVER artifact is an exception. A user with COLLECT_BASIC can
launch it without COLLECT_SERVER, and the server does not check the
artifact’s required_permissions.
implied_permissions has no effect on a SERVER artifact. The verifier
only checks permissions on CLIENT and CLIENT_EVENT artifacts, so there
is no warning for the field to clear.
When event monitoring runs a
SERVER_EVENT artifact, it runs as a
superuser, so required_permissions does not restrict it. To control who
can configure event monitoring, use COLLECT_SERVER, which the monitoring
plugins require.
Impersonating a server artifact
Sometimes you also need to control access to server artifacts. Suppose you
want to let the restricted user create a hunt that contains
Generic.Client.Info.
Creating a hunt requires the Start Hunt permission. Granting that permission lets the user create any hunt, which is dangerous, and you only want to allow one specific hunt.
The wrapper artifact approach works here as well:
name: Start.Hunt.Generic.Client.Info
type: SERVER
sources:
- query: |
SELECT hunt(description="A general hunt",
artifacts='Generic.Client.Info')
FROM scope()This artifact starts a hunt. Mark it as basic and the user can launch it.
The user does not need COLLECT_SERVER for a basic server artifact.
COLLECT_BASIC grants access to it, and the server does not check the
artifact’s required_permissions.
Even though the user can launch the artifact, the collection still fails.
Server artifacts run on the server, where ACL permissions are enforced.
The VQL query runs with the user token, so it can only do what the user is
permitted to do. Marking the artifact as basic lets the user run it, but
the VQL inside it cannot exceed the user’s permissions.
To give the user a controlled privilege to do one specific thing, run the server artifact with different credentials: impersonate the admin user.
name: Start.Hunt.Generic.Client.Info
type: SERVER
impersonate: admin
sources:
- query: |
SELECT hunt(description="A general hunt",
artifacts='Generic.Client.Info')
FROM scope()The impersonate: admin directive tells Velociraptor to run the artifact
with the permissions of the admin user instead of the launching user. This
is similar to the Linux suid mechanism, except that the effect applies to
one artifact rather than to a binary.
When to use impersonation
Use impersonate: when you want to give a low-privileged user one canned
server-side operation, not broad permissions. The artifact must hard-code
the sensitive part of the operation. The user can supply only inputs that
cannot change what the artifact does.
| Goal | Use | Launcher needs |
|---|---|---|
| Run a query as another user for administrative work | query(runas=...) in a notebook, CLI session, or server artifact |
IMPERSONATION |
| Let a low-privileged user run one fixed privileged operation | A SERVER artifact with impersonate: <user> |
COLLECT_BASIC if the artifact is basic; otherwise COLLECT_SERVER plus any required_permissions |
| Let a non-administrator become any user | Don’t. IMPERSONATION is the only way, and it is administrator-equivalent. |
None |
Restrictions and risks
impersonate: only affects SERVER artifacts. Velociraptor sets the field
on every artifact at compile time, but only the server-side collection
context uses it. A CLIENT artifact ignores it.
A custom artifact can only impersonate the user who saves it. Only artifacts loaded by the server itself, including built-in artifacts, can impersonate a different user. This prevents a user with artifact-writing permissions from creating a suid artifact that runs as an administrator.
Do not combine impersonate: with a user-controlled runas
If an artifact sets impersonate: admin and also calls
query(runas=<parameter>) with a parameter the user controls, anyone who
can launch the artifact can become any user, including an administrator.
The artifact is effectively a suid program with an arbitrary user
argument. Hard-code the target, or restrict it to a fixed allowlist.
The artifact is responsible for constraining the privileged operation. If
the user can choose the command, artifact, file path, or other input that
changes what the privileged code does, the artifact is not safe to expose.
For example, Server.Utils.StartHuntExample hard-codes the hunt parameters,
so a user with only COLLECT_BASIC can start that one hunt but cannot start
a different hunt or change its scope.
Hunts and collections created by an impersonating artifact are owned by the impersonated user, and their flows run as that user. The artifact’s fixed logic limits what the launching user can do, but the results are recorded under the impersonated account.
A user without IMPERSONATION who runs query(runas=<other user>) in a
normal server artifact sees an error such as
User alice impersonation to admin: PermissionDenied.
Artifact obfuscation
When you collect an artifact, Velociraptor compiles it into a set of basic VQL statements and sends it to the client in a Collection Request. The Request tab in the GUI shows the raw request.
The client can see the original query while it runs the request. This is a risk for sensitive artifacts. A custom artifact that searches for a sensitive IOC pattern, for example, exposes current threat intel or threat-hunting methodology to a rogue client, such as a compromised endpoint running an attacker-controlled Velociraptor client.
Consider this risk when you craft custom artifacts or collect artifacts that target specific IOCs:
-
Never add sensitive information to the artifact definition. The request strips the artifact description, comments, and some non-essential parts, but variable names remain unaltered.
-
Treat artifact parameters as public information. Never send sensitive IOCs as artifact parameters. Treat API keys the same way: never write a client-side artifact that needs API keys to upload data directly to a service provider. A rogue client can intercept artifact parameters.
-
If you search for a specific IOC that is sensitive, such as a unique name, search for a less sensitive and more generic IOC instead, then post-process the results on the server to remove false positives.
For example, searching for the string
ThreatActorXYZis highly specific, and the threat actor may realize they are being targeted. Search for the regular expressionThreat[^ ]+instead, then filter the false positives on the server.This is a trade-off between specific searches that return few high-value results, and broader searches that risk more false positives while hiding what you are looking for from an adversary.
Velociraptor implements an experimental form of obfuscation for artifact names, but do not treat it as a security mechanism.