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

Drop database will delete /influxdb/data directory #7822

Closed
dmwendt opened this issue Jan 11, 2017 · 2 comments · Fixed by #7829
Closed

Drop database will delete /influxdb/data directory #7822

dmwendt opened this issue Jan 11, 2017 · 2 comments · Fixed by #7829
Assignees
Labels
Milestone

Comments

@dmwendt
Copy link

dmwendt commented Jan 11, 2017

Bug report

System info: InfluxDB v1.1.0 (downloaded, not built), Ubuntu 15.04 64-bit Intel

Steps to reproduce:

  1. Startup InfluxDB and create a database.
    curl -XPOST "http://influxdb:8086/query" --data-urlencode "q=CREATE DATABASE \"Test1\""

  2. Add content to create measurement.
    curl -XPOST 'http://influxdb:8086/write?db=Test1' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
    You should see the /var/lib/influxdb/data directory with Test1 and _internal sub-directories.

  3. Execute 'DROP DATABASE' without a name specifically like the following:
    curl -XPOST "http://influxdb:8086/query" --data-urlencode "q=DROP DATABASE \"\""
    No error is returned or logged but the entire /var/lib/influxdb/data is gone (including _internal).

Expected behavior: Return an error if no database name is provided.

Actual behavior: Deleted the entire /influxdb/data directory.

The DROP DATABASE with no name was a bug in my code where a null name got through but the consequences are pretty bad since all the data files are gone. The system worked ok for a couple days until influxdb was restarted of course. Errors about missing files started appearing only in the logs a few seconds after the drop.

@jwilder jwilder added this to the 1.2.0 milestone Jan 11, 2017
@joelegasse joelegasse self-assigned this Jan 11, 2017
@marcin-github
Copy link

Is it possible to drop database called ../../ ?:)

@dmwendt
Copy link
Author

dmwendt commented Jan 12, 2017

I would be afraid to try that.

joelegasse added a commit that referenced this issue Jan 12, 2017
Fixes #7822

This change first ensures that databases and retention policies exist
before attempting to remove them from the Store. It also adds some
checks in the `DeleteDatabase` and `DeleteRetentionPolicy` to ensure
that maliciously named entries won't remove anything outside of the
configured data directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants