osquery / osquery/osquery

non-UTF8 paths on Linux are not always escaped

Open
#8,204 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Linux localization
Dominant language
C++
Stars
23.6k
Forks
2.6k
Avg merge
6d 7h
Merged PRs (30d)
14

Description

Bug report

What operating system and version are you using?

Linux

What version of osquery are you using?

master

What steps did you take to reproduce the issue?
  1. From a shell create a file with a non-UTF8 character with touch $'file with \x80 non-utf8 name'. Also suppose that this file is in /home/user
  2. With ls verify that the filename should look like 'file_with_'$'\200''_non-utf8_name'
  3. Run this osqueryi query: osqueryi -S 'SELECT * FROM file WHERE path LIKE "/home/user/%"'
  4. Also try with osqueryi -S --json 'SELECT * FROM file WHERE path LIKE "/home/user/%"'
What did you expect to see?

The filename escaped in some way, so that it's still in UTF8

What did you see instead?

image

The problem is that we never escape the results, unless they are in a scheduled query with a differential query, so the same problem exists for results that are either saved locally to log files or sent via network.
More info also in https://github.com/osquery/osquery/issues/7614.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with osqueryi, the file table, and both normal and --json queries using the non-UTF8 filename described. Trace how file-table results are serialized and handled for direct output, saved logs, and network results, also reviewing issue 7614. Done means the path is escaped into valid UTF-8 consistently across these outputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, sql
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.