Skip to content

Commit c0b670a

Browse files
authored
fix(core): Ensure .service does not access Object properties (#3235)
1 parent 818572d commit c0b670a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/feathers/src/application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class Feathers<Services, Settings>
6262
location: L
6363
): FeathersService<this, keyof any extends keyof Services ? Service : Services[L]> {
6464
const path = (stripSlashes(location) || '/') as L
65-
const current = this.services[path]
65+
const current = this.services.hasOwnProperty(path) ? this.services[path] : undefined
6666

6767
if (typeof current === 'undefined') {
6868
this.use(path, this.defaultService(path) as any)

packages/feathers/test/application.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,20 @@ describe('Feathers application', () => {
306306

307307
assert.ok((wrappedService.create as any)[TEST])
308308
})
309+
310+
it('.service does does not access object properties', async () => {
311+
const app = feathers()
312+
313+
assert.throws(() => app.service('something'), {
314+
message: "Can not find service 'something'"
315+
})
316+
assert.throws(() => app.service('__proto__'), {
317+
message: "Can not find service '__proto__'"
318+
})
319+
assert.throws(() => app.service('toString'), {
320+
message: "Can not find service 'toString'"
321+
})
322+
})
309323
})
310324

311325
describe('Express app options compatibility', function () {

0 commit comments

Comments
 (0)