Cacti breaks out from iframe

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
koga
Posts: 1
Joined: Fri Jan 16, 2015 6:04 pm

Cacti breaks out from iframe

Post by koga »

Hi!

I tried to load cacti in icinga tab. Other sites loaded as expected, but cacti takes over the whole browser window.
Can sy help me?
thx :)

(I use http basic auth both for icinga and cacti)

cacti version 0.8.8a
ckong3309
Posts: 1
Joined: Sat Sep 19, 2015 12:17 pm

Re: Cacti breaks out from iframe

Post by ckong3309 »

I had the same problem with Wordpress Advanced iFrame plugin. It's apparently a security feature of Cacti 0.8.8f (where I think 0.8.8b worked). I wondered how something like this would be possible so I went looking and found this site:

http://stackoverflow.com/questions/2896 ... -of-iframe

The key phrase in the article was "Compare top and self, if they're not identical, you are in a frame." So I grep'd for that and found it in this file:

/cacti/include/csrf/csrf-magic.php

...the code:

Code: Select all

    if ($GLOBALS['csrf']['frame-breaker']) {
        $buffer = str_ireplace('</head>', '<script type="text/javascript">if (top != self) {top.location.href = self.location.href;}</script></head>', $buffer);
    }
I made a backup of the file, then commented out the check by adding a # in front of the lines:

Code: Select all

#    if ($GLOBALS['csrf']['frame-breaker']) {
#        $buffer = str_ireplace('</head>', '<script type="text/javascript">if (top != self) {top.location.href = self.location.href;}</script></head>', $buffer);
#    }
It worked. Cacti now appears in an iFrame. The iFrame is too small but that's a different problem to solve. :wink:

Btw, this obviously breaks a probably security feature of Cacti. Make sure you have other protections in effect (like Apache web authentication) before messing with this.
haichai
Posts: 1
Joined: Mon Dec 19, 2005 7:21 am

Re: Cacti breaks out from iframe

Post by haichai »

I m config /usr/share/cacti/site/include/csrf/csrf-magic.php

change $GLOBALS['csrf']['frame-breaker'] = true; to flase

It worked
ZBRR
Posts: 7
Joined: Tue Jun 28, 2022 3:42 am

Re: Cacti breaks out from iframe

Post by ZBRR »

Hi, I know this tred is kinda old but i try to use iframe and in cacti /var/www/cacti/include/vendor/csrf/csrf-conf.php i set the $GLOBALS['csrf']['frame-breaker'] = true; to false and still doesn´t work on iframe, i'm missing some step?
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Cacti breaks out from iframe

Post by TheWitness »

Are you trying to display a Cacti page inside of another Web App?
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
ZBRR
Posts: 7
Joined: Tue Jun 28, 2022 3:42 am

Re: Cacti breaks out from iframe

Post by ZBRR »

It's not in another app its an html file that i create to get cacti graph page with other monitoring stuff.
I found that the problem was CSP. When i added the Header then it worked fine.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Cacti breaks out from iframe

Post by TheWitness »

Yea, we locked that down out of the box due to a bunch of security people providing negative feedback unless it was added. It's open source, so you can always unwind it.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests