Skip to content

Question about untrusted user input #4

@madjar

Description

@madjar

Hi there!

First of all, thanks for publishing this set of rdf-related libraries, I've been having a lot of fun getting back in LD and using them.

I encountered something while building a small app on top of this, and I wondered if you might have some thoughts on this: how to handle (potentially untrusted) user input in SPARQL queries?

The two approaches I usually see in SQL are

  • To use some form of placeholders in the query (eg WHERE id = ?). It doesn't seem to be an option in sparql-ex, nor in another implementation of SPARQL I was looking at (oxigraph).
  • String concatenation with explicit escaping (though the previous option is often preferred). A few hits on stackoverflow (https://stackoverflow.com/questions/29601839/standard-regex-to-prevent-sparql-injection) suggest that this can be done in sparql by using triple quotes and escaping all backslashes, and single and double quotes.

Is that a topic you've encountered? If so, how do you usually deal with this?

I'd be happy to write a bit of documentation with what I can learn on the topic, if that sounds interesting to you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions