misusing oop in mvc frameworks - zeronights 2019...not about oop misuse in general, but rather a...

30
Misusing OOP in mvc frameworks

Upload: others

Post on 12-Jun-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Misusing OOP in mvc frameworks

Disclaimer

● No new super-puper attack techniques● No new mind-blowing vulnerabilities● Not about OOP misuse in general, but rather a single OOP principle

2

Disclaimer

● No new super-puper attack techniques● No new mind-blowing vulnerabilities● Not about OOP misuse in general, but rather a single OOP principle ● Which is Inheritance. in MVC frameworks.

3

Disclaimer

● No new super-puper attack techniques● No new mind-blowing vulnerabilities● Not about OOP misuse in general, but rather a single OOP principle ● Which is Inheritance. in MVC frameworks.

4

Model–View–Controller (usually known as MVC) is a software design pattern[1] commonly used for developing user interfaces which divides the related program logic into three interconnected elements. This is done to separate internal representations of information from the ways information is presented to and accepted from the use

(c) wikipedia

MVC in 3 words

5

View(template) Model

Controller

User

MVC in 3 words

6

URL matching

Routing tableurl1 -> handler1url2 -> handler2...urlN -> handlerN

handler

Controller+ method

Request

Disclaimer

● No new super-puper attack techniques● No new mind-blowing vulnerabilities● Not about OOP misuse in general, but rather a single OOP principle ● Which is Inheritance. in MVC frameworks.

7

In object-oriented programming, inheritance is the mechanism of basing an object or class upon another object (prototype-based inheritance) or class (class-based inheritance), retaining similar implementation

(c) wikipedia

Private ControllerAllows authorized users to manipulate stuff

8

Inheritance is the thing

PrivateAPI

# fetchStuff+ getStuff+ editStuff+ deleteStuff

- stuff

Private ControllerAllows authorized users to manipulate stuff

Now you want to show some public stuff to anonymous users as well• But you don't want to re-invent

code

9

Inheritance is the thing

PrivateAPI

# fetchStuff+ getStuff+ editStuff+ deleteStuff

- stuff

Private Controller Public Controller

10

Inheritance is the thing

PrivateAPI

# fetchStuff+ getStuff+ editStuff+ deleteStuff

- stuff

PublicAPI

+ getPublicStuffInherits

Public Controller

11

Inheritance is the thing

PublicAPI

# fetchStuff+ getPublicStuff

- stuff

Now we can utilize protected methods of a parent class

Public Controller

12

Inheritance is the thing

PublicAPI

# fetchStuff+ getPublicStuff+ getStuff+ editStuff+ deleteStuff

- stuff

Now we can utilize protected methods of a parent class• But also all the other methods as

well

How to find (or more like how do I find it. Which is probably the worst way of doing it)

• Gather a list of registered routes-Using debug and monitoring features of frameworks

• Parse the list for similar endpointsSuch as: - /admin/whatever/endpoint

- /public/whatever/endpoint

• Try to access similar routes with the same user role

13

Very Important slide (no)

Examples

The above can turn out to be really sad, as the examples below might (or might not) show

14

Private Controller• Has action mapped to:

Controller prefix + action route = /admin/user-list

15

Examples. PHP + Symfony

Private Controller• Has action mapped to:

Controller prefix + action route = /admin/user-list

• Has access control policies properly set:

access to /admin is only allowed to users with role ROLE_ADMIN

16

Examples. PHP + Symfony

Examples. PHP + Symfony

17

Public Controller• Inherited from Private controller

(because reasons)

18

Examples. PHP + Symfony

Public Controller• Inherited from Private controller

(because reasons)

• Has access control policies properly set:

aсcess to /user is allowed to any user with role ROLE_USER

19

Examples. PHP + Symfony

Examples. PHP + Symfony

20

How to catch. Symfony debug command (through bin/console)php bin/console debug:router

21

Examples. PHP + Symfony

Private Controller• Has action mapped to:

Controller prefix + action route = /private/admin

22

Examples. Java + Spring MVC

Private Controller• Has action mapped to:

Controller prefix + action route = /private/admin

• Has access control policies properly set:

access to /private is only allowed to users with ADMIN role

23

Examples. Java + Spring MVC

Examples. Java + Spring MVC

24

Public Controller• Inherited from Private controller

(because reasons)

25

Examples. Java + Spring MVC

Public Controller• Inherited from Private controller

(because reasons)

• Has access control policies properly set

aсcess to /user is allowed to any user with role ROLE_USER

26

Examples. Java + Spring MVC

Examples. Java + Spring MVC

27

How to catch. Spring boot actuator

28

Examples. Java + Spring MVC

http://localhost:8080/mappings

29

Examples. Other frameworks(Well, potential examples to be honest)

● ruby on rails (+ devise + cancan) - to some extent

● node.js (stuff like sails.js)

@author

THANKS FOR ATTENTION