Fork me on GitHub
#reitit
<
2022-12-05
>
Ben Sless10:12:10

Does route data get merged with the top level ring router and any route maps along the way?

ikitommi12:12:36

Hi, I believe it should.

Ben Sless16:12:58

well, I accidentally found an attack vector on reitit via coercion: On -encode-error, the schema and errors get serialized with edn, which is extremely expensive. Since schema and errors return by default from coercion, it is possible to induce extreme load on a server with complex schema by sending invalid requests

(-encode-error [_ error]
         (cond-> error
           (show? :humanized) (assoc :humanized (me/humanize error {:wrap :message}))
           (show? :schema) (update :schema edn/write-string opts)
           (show? :errors) (-> (me/with-error-messages opts)
                               (update :errors (partial map #(update % :schema edn/write-string opts))))
Proposed fix - remove schema and errors from default options
:error-keys #{:type :coercion :in :schema :value :errors :humanized #_:transformed}

👍 1