Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

513
Visualizações
What is constructor.constructor()() in JavaScript?

I'm bug hunting on h1 and I've found a way to trigger an alert box using constructor.constructor() on a site using Angularjs, Nodejs and other JavaScript libraries and I am looking to truly understand what is going on here, but haven't found the exact piece of information.

The exact payload is

constructor.constructor('alert(1)')()

I have only found info talking about constructors as in the process of defining functions and classes but not as a "function" (not really sure what this is in this context). And I'm not sure if the context that triggers the alert box is one of the libraries in place or just because of JavaScript and the DOM.

Does anybody know what constructor.constructor()() is? And how does it work?

PS: The payload is also placed inside {{ }} but it is apparently just JavaScript and not an actual SSTI (7*7 is parsed by DOM but remains in source code)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Object instances have a reference to their constructor function:

const o = {};
o.constructor === Object;

If you don't reference any object, you're executing the property in the global context off of the window instance, which is the same as window.constructor:

constructor /* or window.constructor */ === Window;

Window and Object are function instances, because functions are also objects in JavaScript which means that the constructor is Function

constructor.constructor /* or Window.constructor */ === Function;

The Function function can be used to create a function instance using the string input as the function body—similar to eval—so in your example of passing in 'alert(1)' the result is a function that calls alert(1) when executed:

Function('alert(1)');
// is the same as
function () {
  alert(1);
}

And finally the last parentheses execute the function without any parameters, which is why you see the alert displayed with a 1.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda