Skip to content

Add safe LOCAL INFILE support - #215

Open
iagocavalcante wants to merge 1 commit into
elixir-ecto:masterfrom
iagocavalcante:local-infile
Open

iagocavalcante wants to merge 1 commit into
elixir-ecto:masterfrom
iagocavalcante:local-infile

Conversation

@iagocavalcante

Copy link
Copy Markdown
Contributor

Summary

  • add an explicit per-query :local_infile file path for text queries
  • advertise CLIENT_LOCAL_FILES and decode the 0xFB filename as an EOF string
  • stream only the caller-selected file in protocol-sized packets
  • keep connections synchronized when the source is missing, invalid, or cannot be read

Security

A MySQL server can request a different client-side path from the one named in the SQL statement. To avoid arbitrary file disclosure, this implementation ignores the server-provided filename and requires callers to pass an explicit path for each query:

MyXQL.query(conn, sql, [],
  query_type: :text,
  local_infile: "/path/to/data.csv"
)

This supersedes #204 and follows the safe, explicit-source direction discussed in #110.

Testing

  • mix compile --warnings-as-errors
  • mix test --exclude requires_otp_19 against MySQL 8.4
  • 215 tests, 0 failures, 2 skipped (8 excluded by environment/tag configuration)

Closes #203

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LOCAL INFILE option was not working as expected

1 participant