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

TypeORM + Postgres: HStore implementation broken & subject to "hstore injection" #4719

Closed
tobyhinloopen opened this issue Sep 10, 2019 · 1 comment · Fixed by #4720
Closed

Comments

@tobyhinloopen
Copy link
Contributor

tobyhinloopen commented Sep 10, 2019

Issue type:

[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x] latest (0.2.18)
[ ] @next
[x] 0.2.18 (or put your version here)

Steps to reproduce or a small repository showing the problem:

For an Entity column like this:

class Thing {
  // ...
  @Column({ type: "hstore", hstoreType: "object" })
  public values: Record<string, string>;
}

The values property is not restored properly when saving & restoring the
entity: Empty string values in the map (EG { foo: "1", bar: ""} cause the object to break.

For clarity & reproduction, I've created an isolated bare-minimum repository that acts as an example of the issue.

See https://github.com/tobyhinloopen/typeorm-failure for a runnable example.

@tobyhinloopen
Copy link
Contributor Author

    const thing = new Thing();
    thing.values = { username: `", admin=>"1`, admin: "0" };
    await thingRepo.save(thing);
    const foundThing = await thingRepo.findOneOrFail();
    console.log(foundThing.values); // { admin: '1' }

🤔

@tobyhinloopen tobyhinloopen changed the title TypeORM + Postgres: HStore with empty string values broken TypeORM + Postgres: HStore implementation broken & subject to "hstore injection" Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant