Konloch/bytecode-viewer · error · SecurityException

BCV is awesome, blocking write(

Error message

BCV is awesome, blocking write(

What it means

SecurityMan.checkWrite throws SecurityException when code under BCV's sandbox attempts to write to a file that is not permitted; the final throw blocks the write and reports the file path. This prevents plugins or analyzed code from modifying arbitrary host files. Some permitted paths (e.g. BCV's own working outputs) pass through earlier,IOException wraps failures there.

Source

Thrown at src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java:387

                || file.endsWith(".json")
                || file.endsWith(".txt")
                || file.endsWith(".log"))
                return;

            //can only write into BCV dir
            if (file.startsWith(Constants.BCV_DIR.getCanonicalPath()))
                return;

            //can only write into system temp
            if (file.startsWith(Constants.SYSTEM_TEMP_DIRECTORY))
                return;
        }
        catch (IOException e)
        {
            throw new SecurityException(e);
        }

        throw new SecurityException("BCV is awesome, blocking write(" + file + ");");
    }
}

View on GitHub (pinned to 31430e0033)

Solutions

  1. Write only to BCV-sanctioned locations (its temp/working directory) from plugin code
  2. Pre-create and use files under the allowed output directory instead of arbitrary paths
  3. Adjust SecurityMan's write policy in a local build if a specific path must be writable
  4. Avoid file I/O in analyzed code paths triggered during analysis

Example fix

// before
new FileWriter("/etc/mytool.cfg"); // SecurityException
// after
File out = new File(Configuration.getBCVDirectory(), "mytool.cfg");
new FileWriter(out); // inside BCV's permitted write area
Defensive patterns

Strategy: try-catch

Validate before calling

File target = new File(path);
String allowed = the.bytecode.club.bytecodeviewer.Configuration.getBCVDirectory();
if (!target.getCanonicalPath().startsWith(new File(allowed).getCanonicalPath()))
    throw new IllegalStateException("Write outside allowed BCV directory will be blocked: " + target);

Try / catch

try {
    Files.write(target, data);
} catch (SecurityException e) {
    if (e.getMessage().startsWith("BCV is awesome, blocking write")) {
        // redirect to BCV's allowed output directory
    } else throw e;
}

Prevention

When it happens

Trigger: Plugin or analyzed code calls FileOutputStream/Files.write/etc. on a path not approved by SecurityMan's write policy while the SecurityManager is active.

Common situations: Plugins writing temp/output files outside allowed directories; analyzed libraries writing config or logs on first run; tools expecting to persist state anywhere on disk during analysis.

Related errors


AI-assisted analysis of Konloch/bytecode-viewer@31430e0033 (2026-09-05). Data as JSON: /api/errors/3139f1ba04eae951. Report an issue: GitHub.