Skip to content

Input mapping is buggy #310

@gibson042

Description

@gibson042

This package commits the cardinal sin of escaping: failing to fully exempt non-escaped input from unescaping (e.g., escapeKey escapes each . as \. but fails to escape \ itself). As a result, there are some injection bugs: https://jsfiddle.net/euqLwk4r/

input

({
  a: [ "/'a'[0]: string that becomes a regex/" ],
  'a.0': /'a.0': regex that becomes a string/,
  'b.0': "/'b.0': string that becomes a regex/",
  'b\\': [ /'b\\'[0]: regex that becomes a string/ ],
})

encodes to

{
  "json": {
    "a": [ "/'a'[0]: string that becomes a regex/" ],
    "a.0": "/'a.0': regex that becomes a string/",
    "b.0": "/'b.0': string that becomes a regex/",
    "b\\": [ "/'b\\\\'[0]: regex that becomes a string/" ]
  },
  "meta": {
    "values": {
      "a.0": [ "regexp" ],
      "b\\.0": [ "regexp" ]
    }
  }
}

which decodes as the input-dissimilar

({
  a: [ /'a'[0]: string that becomes a regex/ ],
  'a.0': "/'a.0': regex that becomes a string/",
  'b.0': /'b.0': string that becomes a regex/,
  'b\\': [ "/'b\\\\'[0]: regex that becomes a string/" ],
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions